I have an Angular material component that I am trying to update dynamically with new data.
@ViewChild('tree') tree: MatTree<any>;
...
treeControl: NestedTreeControl<any>;
dataSource: MatTreeNestedDataSource<any>;
...
// This does not work
this.tree.renderNodeChanges(newData);
I can change the data source data just fine and it is reflected in the logs, but the tree is never re-rendered this.dataSource.data = newData
;
This data is retrieved from an observable and I pass it in every time there is a change.
<mat-tree [dataSource]="dataSource"
[treeControl]="treeControl"
#tree
class="release-notes-tree">
...
</mat-tree>
What is the easiest way to just pass in brand new data and update the tree?
Can't you just make the dataSource a Subject then when you want to change it call dataSource.next() ?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With