how to initialize primeng tree component

前端 未结 3 1498
春和景丽
春和景丽 2021-02-06 19:37

Given a tree how to initialize it in such way that the nodes are expanded at will?

I already tried to get a reference with @ViewChildren(Tree) tree

3条回答
  •  無奈伤痛
    2021-02-06 20:02

    You can handle this with a function that put all the expanded attributes to true.

    expandAll(toggle: boolean) {
      this.tree.map(node => {
        node.expanded = toggle;
      });
    }
    
    ngOnInit() {
      setTimeout(()=>{
        this.expandAll(true);
      }, 0);
    
    }
    

提交回复
热议问题