角度材质树展开特定节点

and*_*enX 5 tree expand angular-material2 angular

我已经看到各种示例来使用扩展 mat-tree 中的所有节点

expandAll()
Run Code Online (Sandbox Code Playgroud)

如果我们点击它,是否有任何机制可以扩展特定节点。就像是

node.expand()
Run Code Online (Sandbox Code Playgroud)

我已经提到了 angular material 文档,但没有得到任何答案。如果有人经历过,请指导。

bug*_*ugs 18

您正在寻找的是expandon 方法treeControl,它对treeControl.dataNodes数组进行操作。

就像是

this.treeControl.expand(this.treeControl.dataNodes[/** node you want to expand **/]);
Run Code Online (Sandbox Code Playgroud)

请记住,如果您想扩展一个特定的节点,它的所有祖先直到根节点也需要扩展。


演示