{
path: 'project/:id',
component: ProjectComponent,
resolve: { data: DataResolver },
data: { path: 'project/:id' }
}
class DataResolve implements Resolve<string> {
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
return route.data['path'];
}
}
return new Observable<Item>(subscriber => {
// tslint:disable-next-line
const itemId = route.params.id;
this.db.findItemByItemId2(itemId).subscribe(value => {
subscriber.next(value);
subscriber.complete();
});
});
References
https://stackoverflow.com/questions/40297165/angular-2-pass-a-value-to-the-route-data-resolve/49171861
Related