1
votes

Docs: https://material.angular.io/components/tree/overview#nested-tree

This is exactly the same that I want to do, but I need the parent of a node. How to get it on the template?

I am thinking on something like this:

<li class="mat-tree-node" (click)="smthingFn(node)">
  <button mat-icon-button disabled></button>
  {{node.filename}}:  {{node.type}}
</li>


smthingFn(node):void {
   console.log(node.parent.filename);
}
1

1 Answers

0
votes

You should make use of a Treecontrol. You can use this control to get children, level of node etc.

Check this example out for more information on how to use it.

Tree with tree control

Also I am not really sure about your code there, it looks like you are trying to use a list to do this but the question is marked with Angular Material Tree. Read up on how to implement the Material Tree.