Skip to content

help(mat-tree-node): Dynamically filling the tree using service cause 1 "selected" object to disappear from screen #20122

@profeciak

Description

@profeciak

What are you trying to do?

I want to use mat-tree-node to present selected nodes from main tree, also as trees. I'm getting the values using Subscription like :
this.chosenProjectsPhasesOrTasksService.getListOfChosenElements().subscribe((value: TreeDataModel[]) => {
console.log(value)
this.dataSource.data = [];
console.log(this.dataSource.data)
this.dataSource.data = JSON.parse(JSON.stringify(value));
console.log(this.dataSource.data)
});
and I can see for example that this.dataSource.data has 4 elements, but on the screen there are only 3

What troubleshooting steps have you tried?

After choosing first value I got it on screen - It's ok. But when I choose more values, then the first one disappears from the screen even though it's still in this.dataSource.data as I've checked in console.log

Environment

  • Angular: 7.2.0
  • CDK/Material: 7.2.0
  • Browser(s): chrome, firefox
  • Operating System (e.g. Windows, macOS, Ubuntu): Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: clarificationThe issue does not contain enough information for the team to determine if it is a real bugtroubleshootingThis issue is not reporting an issue, but just asking for help

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions