angular - CanActivateChildGuard after CanActivateGuard resolve in Angular4 -
i have routing in angular 4 looks this:
let routes: routes = [ { path: '', redirectto: redirect_after_login, pathmatch: 'full'}, { path: 'passwordreset/:token', component: passwordresetcomponent }, { path: 'app', component: appcomponent, children: app_child_routing }, { path: 'pages', component: pagescomponent, canactivate: [canactivateappguard], canactivatechild: [canactivateappguard], data: {breadcrumb: 'breadcrumb.home'}, children: child_routing } ];
when trigger pages child route (which after login because redirect_after_login variable contains 1 of pages child routes) want execute 2 api calls in direct order: 1. api call server token <-- canactivate 2. api call additional info requires send server token <-- canactivate child.
those api methods observables, canactivate start running , before resolves (return true guard) canactivatechild fired resolves in error.
canactivate():observable<any>{ return this.loginservice.getuserinfo().map(()=>{ return true; }).catch(()=>{ this.redirect(location.origin + "/login"); return observable.of(false); }) } canactivatechild():observable<any>{ return this.common.retrievecontext().map( res=>{ //do sth return true; }, err=>{ //do sth else return observable.of(true); } ) }
i want find way canactivatechild guard fired when canactivate guard has been resolved.
Comments
Post a Comment