【发布时间】:2017-02-21 11:49:47
【问题描述】:
我正在尝试同时进行多个 ajax 调用。 我无法弄清楚这些行有什么问题。好像订阅函数的第二个输入被处理为 Group[] 而不是 Authorization[]
Observable.forkJoin(
[this.userService.getAllGroups(),this.userService.getAllAuthorizations()]
)
.subscribe(
([groups,authorizations]) => {
this.groups = groups;
this.authorizations = authorizations; //error: Type 'Group[]' is not assignable to type 'Authorization[]'
this.loaderService.hideLoader();
},
(err)=>{
this.loaderService.hideLoader();
}
);
接口是:
(method) UserService.getAllGroups(): Observable<Group[]>
(method) UserService.getAllAuthorizations(): Observable<Authorization[]>
谁能帮我理解问题出在哪里?
【问题讨论】:
-
([groups,authorizations]) =>应该做什么? -
console.log(groups, authorizations)在subscribe(...)回调中添加为第一行时会打印什么?
标签: class angular observable subscribe