CirclonGroup / angular-tree-component

A simple yet powerful tree component for Angular (>=2)

Home Page:https://angular2-tree.readme.io/docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expanding specific node on ngAfterViewInit

bartoooon opened this issue · comments

Hello,
I am following the angular-tree-component/guide more specifically where it explains how to expand nodes on init (https://circlongroup.github.io/angular-tree-component/guides/expanding)

I am trying to open a specific (mocked at the moment) node by using: this.tree.treeModel.getNodeById(64333);
but i can't make it work... i keep getting that "someNode" is undefined

this is my tree:
<tree-root #tree (focus)="focusNode($event)" (toggleExpanded)="onExpand($event)" (moveNode)="onMoveNode($event)" [nodes]="nodeList" [options]="options" class="tree-wrapper bold-node-text level1-document-icon-only m-b-20"> . . . . </tree-root>

ts:
@ViewChild('tree') tree; ngAfterViewInit() { const someNode = this.tree.treeModel.getNodeById(64333); someNode.expand(); }