Recently, I've been working on creating a tree structure to handle dynamic data using Angular material tree component. In order to achieve this, I referred to the code example mentioned below:
https://stackblitz.com/edit/material-tree-dynamic
However, I encountered an issue with the tree structure I developed, where the collapse functionality was not working as expected. I decided to copy the code from the above example and run it on my own machine. Here is the TypeScript file I used (the HTML code remained the same):
import {Component, Injectable} from '@angular/core';
import {FlatTreeControl} from '@angular/cdk/tree';
import {CollectionViewer, SelectionChange} from '@angular/cdk/collections';
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
import {Observable} from 'rxjs/Observable';
import {merge} from 'rxjs/observable/merge';
import {map} from 'rxjs/operators/map';
// code continues...
Upon collapsing a root node that contains multiple levels of children, the resulting display can be seen here.
If anyone has insights into what might be causing this issue and how to resolve it, I would greatly appreciate the assistance.