Npm 角度树组件异步子级未加载?

Npm 角度树组件异步子级未加载?,npm,save,installation,angular-tree-component,Npm,Save,Installation,Angular Tree Component,我正在使用npm安装--保存角度树组件当我单击父节点时,子节点未加载它显示“正在加载…”消息这里是我的代码 options: ITreeOptions = { getChildren: this.getChildren.bind(this) }; getChildren(node: any) { debugger this.TreeService.getChildren((callback) => { this.asyncChildren =

我正在使用npm安装--保存角度树组件当我单击父节点时,子节点未加载它显示“正在加载…”消息这里是我的代码

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);
      });
    });
  }

看起来您没有返回承诺(typescript定义有点打开,它只希望返回值为“any”)。如上所述,您必须返回承诺或数组

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);
  });
});
}