In the new Angular Material Tree component, this is a part of the markup used in the examples (Angular Material tree with flat node example):
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding>
<button mat-icon-button matTreeNodeToggle
[attr.aria-label]="'toggle ' + node.filename">
<mat-icon class="mat-icon-rtl-mirror">
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
</button>
{{node.filename}} : {{node.type}}
</mat-tree-node>
Note that there is an interpolation inside the mat-icon tag which determines which icon to show.
I am using font awesome in my project instead of the Material Design icons, so I am trying to find a way to make the tree component work with font awesome icons.
So far I have tried to replace the mat-icon tag with the following:
<i class="{{treeControl.isExpanded(node) ? 'fas fa-chevron-down' : 'fas fa-chevron-right'}}"></i>
I also tried where Font Awesome is registered so that I can use this:
<mat-icon fontIcon="{{treeControl.isExpanded(node) ? 'fa-chevron-down' : 'fa-chevron-right'}}"></mat-icon>
In both cases, the chevron-right icon appears initially, and clicking to expand works, but the icon does not change. However, if I expand several levels, then collapse the top level, then expand the top level again, all the lower levels show the correct icon (chevron-down).
It seems that treeControl.isExpanded(node) is not executing at the expected time (when the icon button is clicked). Are there any solutions for this problem?
Here is a stackblitz which demonstrates the problem: https://stackblitz.com/edit/angular-fx4glo?file=app%2Ftree-flat-overview-example.html