Class 角形2-叉连接can';别系对了
我正在尝试一起执行多个ajax调用。 我想不出这些线路有什么毛病。似乎subscribe函数的第二个输入被处理为组[],而不是授权[]Class 角形2-叉连接can';别系对了,class,angular,observable,subscribe,Class,Angular,Observable,Subscribe,我正在尝试一起执行多个ajax调用。 我想不出这些线路有什么毛病。似乎subscribe函数的第二个输入被处理为组[],而不是授权[] Observable.forkJoin( [this.userService.getAllGroups(),this.userService.getAllAuthorizations()] ) .subscribe( ([groups,authorizations]) =>
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[]>
(方法)UserService.getAllGroups():可观察
(方法)UserService.getAllAuthorizations():可观察
任何人都可以帮助我了解问题所在吗?试着这样做:
Observable.forkJoin(
this.userService.getAllGroups(),
this.userService.getAllAuthorizations()
).订阅(结果=>{
this.groups=结果[0];
此参数=结果[1];
);
或
Observable.forkJoin(
this.userService.getAllGroups(),
this.userService.getAllAuthorizations()
).订阅((组、授权)=>{
这个组=组;
这是授权=授权;
);
像这样尝试:
Observable.forkJoin(
this.userService.getAllGroups(),
this.userService.getAllAuthorizations()
).订阅(结果=>{
this.groups=结果[0];
此参数=结果[1];
);
或
Observable.forkJoin(
this.userService.getAllGroups(),
this.userService.getAllAuthorizations()
).订阅((组、授权)=>{
这个组=组;
这是授权=授权;
);
什么是([groups,authorizations])=>
应该做什么?console.log(groups,authorizations)
在订阅(…)
回调中作为第一行添加时打印什么?什么是([groups,authorizations])=>
应该做什么?什么是console.log(groups,authorizations)
在订阅(…)中作为第一行添加时打印。
回调?