0

I am using npm install --save angular-tree-component child nodes are not loaded when i click parent it shows "loading..." message here is my code

options: ITreeOptions = {
    getChildren: this.getChildren.bind(this)
  };

  getChildren(node: any) {
    debugger
    this.TreeService.getChildren((callback) => {
      this.asyncChildren = callback;             
      const newNodes = this.asyncChildren.map((c) => Object.assign({}, c));
      return new Promise((resolve, reject) => {
        setTimeout(() => resolve(newNodes), 1000);
      });
    });
  }

1 Answers1

0

Looks like you missing to return the promise (the typescript definition is a bit to open, it only expecting 'any' as return value). As descripted here you have to return a promise or a array.

getChildren(node: any) {
debugger
return /*missing return*/ this.TreeService.getChildren((callback) => {
  this.asyncChildren = callback;             
  const newNodes = this.asyncChildren.map((c) => Object.assign({}, c));
  return new Promise((resolve, reject) => {
    setTimeout(() => resolve(newNodes), 1000);
  });
});

}

Flo
  • 122
  • 1
  • 1
  • 8