0
我有一個路線:角路由器嵌套解析(S)
const routes: Routes = [
{
path: ':id',
component: MoyComponent,
resolve: {
first: MyFirstResolver
second: mySecondResolver(first)
}
}
我有一個解析器:
@Injectable()
export class MyFirstResolver implements Resolve<any> {
constructor(private ms: MyService, private router: Router) {}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<any> {
let id = route.params['id'];
return this.ms.get(id).map(res => {
if (res) {
return res;
} else {
this.router.navigate(['/']);
return null;
}
});
}
}
MyFirstResolver
返回一個對象obj
,我想傳遞obj['price']
到mySecondResolver
如mySecondResolver
取決於obj
的price
財產。我怎樣才能將結果從myFirstResolver
傳遞到mySecondResolver
?
你有兩個'return語句' – Aravind
我不明白@Aravind – Moshe
你可能需要將它們合併到它自己的解析器中。理論上講,你可以簡單地創建一個ThirdResolver類,導入前兩個,並將它們鏈接在一起。 – wilsonhobbs