我正在使用npm install --save angular-tree-component子节点不加载当我单击父节点时,它显示“正在加载...”以下消息是我的代码
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);
});
});
}发布于 2020-03-16 20:22:43
看起来您缺少返回promise ( typescript定义有点难打开,它只需要'any‘作为返回值)。作为描述的here,您必须返回promise或数组。
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);
});
});}
https://stackoverflow.com/questions/58222427
复制相似问题