satmisha
asked on
Dynamically bind the data to the child drop down from the API
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You Misha.
Can I attach the dynamic data to the Mat tree, consider the same example but with Mat Tree ? I am sorry I didn't incorporate this in the requirement, if you want I will create another ticket for that.
Can I attach the dynamic data to the Mat tree, consider the same example but with Mat Tree ? I am sorry I didn't incorporate this in the requirement, if you want I will create another ticket for that.
Yes, you can use dynamic data it Mat tree. Example is on official Angular site
https://material.angular.io/components/tree/examples
There is one of examples from site:
Please detail your question about Mat Tree...
https://material.angular.io/components/tree/examples
There is one of examples from site:
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl"> <!-- This is the tree node template for leaf nodes --> <mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding> <!-- use a disabled button to provide padding for tree leaf --> <button mat-icon-button disabled></button> {{node.name}} </mat-tree-node> <!-- This is the tree node template for expandable nodes --> <mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding> <button mat-icon-button matTreeNodeToggle [attr.aria-label]="'Toggle ' + node.name"> <mat-icon class="mat-icon-rtl-mirror"> {{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}} </mat-icon> </button> {{node.name}} </mat-tree-node>
</mat-tree>
You can populate dataSource dynamically dataSource = new MatTreeFlatDataSource(,....)
this.dataSource.data = YourData;
You can get this data from parent component too.Please detail your question about Mat Tree...
ASKER