控制台向我输出此错误:“ TypeError:无法读取未定义的属性'then'”。任何帮助表示赞赏。最好的帮助是了解我在解决此问题时的错误。
ngOnInit() : void {
super.ngOnInit();
this.prerequisites = Promise.all([
this.apiClient.getResources(ClientGroupResource, {order: 'title ASC'}),
this.apiClient.getResources(SettingResource)
]).then(results => {
this.groups = <any>results[0];
let settings : ResourceList<SettingResource> = <any>results[1];
for (let i : number = settings.items.length; i--;) {
if (settings.items[i].key == 'color_booking') {
this.defaultBookingColor = settings.items[i].value;
} else if (settings.items[i].key == 'color_recurring_booking') {
this.subscriptionBookingColor = settings.items[i].value;
}
}
}).catch(e => {
this.handleError(e);
});
this.routeReady()
}
routeReady() : void {
super.routeReady();
this.activeRoute.params.pipe(
switchMap((params : Params) => {
return this.prerequisites.then(() => {
return this.loadPageData(params);
});
}))
.subscribe();
}
loadpage链接中的功能代码
答案 0 :(得分:0)
您需要在belwo代码内返回值
this.prerequisites = Promise.all([
this.apiClient.getResources(ClientGroupResource, {order: 'title ASC'}),
this.apiClient.getResources(SettingResource)
]).then(results => {
return results;
.....
});