1
我有兩個函數,我想調用,但我只想在第一個函數完成後調用第二個函數。我該如何去做呢?TypeScript/Angular 2 - 在另一個完成後調用一個函數
首先功能:
getDirectorySubfolders(node: any) {
console.log('Home:getDirectorySubfolders() entered...');
this._sdiService.getDirectoriesAtPath("Desktop")
.subscribe(res => {
this.nodeChildren = res;
});
}
二功能:
getChildren(node: any) {
console.log('Home:getChildren entered..');
return new Promise((resolve, reject) =>
{
setTimeout(() => resolve(this.nodeChildren.map((c) =>
{
return Object.assign({}, c, {});
})), 1000);
});
}