Pass a value to the Resolver on Angular

{
  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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.