Expanding nodes on init
A common use case is to start with the tree expanded completely.
You can achieve this by calling treeModel.expandAll() after view init:
<tree-root #tree [nodes]="nodes"></tree-root>
@Component {
nodes = [...];
@ViewChild('tree') tree;
ngAfterViewInit() {
this.tree.treeModel.expandAll();
}
}
Or to expand / activate specific nodes:
<tree-root #tree [nodes]="nodes"></tree-root>
@Component {
nodes = [...];
@ViewChild('tree') tree;
ngAfterViewInit() {
const someNode = this.tree.treeModel.getNodeById('someId');
someNode.expand();
const firstRoot = this.tree.treeModel.roots[0];
firstRoot.setActiveAndVisible();
}
}
Updated less than a minute ago