Skip to content

Does mat-tree support MatNestedTreeNode.level property? #17945

Closed
@sdwske

Description

@sdwske

Reproduction

Use StackBlitz to reproduce your issue: https://stackblitz.com/edit/components-issue-dew9or

Steps to reproduce:

  1. Just look at console log after it (tree) loads. Contents of the tree are not a subject of the issue - only the console error.

ERROR TypeError: "_co.treeControl.getLevel is not a function"

Expected Behavior

API notes presence of level property - for both flat and nested nodes.
https://material.angular.io/components/tree/api#MatNestedTreeNode
treeControl.getLevel(dataNode) should be able to retrieve it, right?

Actual Behavior

Using:

{{treeControl.getLevel(dataNode)}}

...is apparently broken? Or not documented well.
I've also tried accessing "level" property through:

@ViewChildren(MatNestedTreeNode)
nestedNodes: QueryList<MatNestedTreeNode<Privilege>>;

...but it always returns 0, no matter when or what node You ask.

It seems like level property is never set, nor supported by treeControl.

Should or will level property be supported in nested nodes?

Environment

  • Angular: 8.2.14
  • CDK/Material: 8.2.3
  • Browser(s): Any/All (tested on Firefox)
  • Operating System (e.g. Windows, macOS, Ubuntu): Any/All

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2The issue is important to a large percentage of users, with a workaroundarea: material/tree

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions