i need to return data from tow api in angular 8.
i create this resolver:
export class AccessLevelResolve implements Resolve<any>{
constructor(private accessLevel: AccessLevelService) { }
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> {
let id = +route.paramMap.get('id');
const getControllerList = this.accessLevel.getAll().pipe(
map(
res => {
if (res) {
return res.date;
}
}
)
)
const getRoleAccessRole = this.accessLevel.getAllWithId(id).pipe(
map(
res => {
if (res) {
return res.date;
}
}
)
)
return forkJoin(getControllerList, getRoleAccessRole).subscribe(res => {
return {
controllerList: res[0],
accessRoleList: res[1]
}
}
)
}
but it show me this error:
Type 'Subscription' is missing the following properties from type 'Observable': _isScalar, source, operator, lift, and 6 more.
whats the problem??? how can i solve this problem??
you don't subscribe in your resolver, you return the observable and angular subscribes:
return forkJoin(getControllerList, getRoleAccessRole).pipe(map(res => {
return {
controllerList: res[0],
accessRoleList: res[1]
}
}))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.