- I have a corner installation that uses two guards.
canLoad and canActivate - both get the same observable from @ angular-redux / store via
@select
Question : Why canActivate works with observable, @select returns canLoad and since then canLoad interrupted all routing? What is the difference between the two guards?
Related Angular Problem: https://github.com/angular/angular/issues/18991
auth.guard.ts
@Injectable() export class AuthGuard implements CanLoad, CanActivate { @select() readonly authenticated$: Observable<boolean>; // @angular-redux/store canLoad(): Observable<boolean> | boolean { // return true; // works return this.authenticated$; // ERROR: all routing stops from and to the current page } canActivate(): Observable<boolean> | boolean { // return true; // works return this.authenticated$; // works } }
application-routing.module
const routes: Routes = [ { path: '', component: SomeAComponent, pathMatch: 'full' }, { path: 'someb', component: SomeBComponent, canActivate: [ AuthGuard ], }, { path: 'lazy', loadChildren: './lazy/lazy.module#LazyModule', canLoad: [ AuthGuard ] }, { path: '**', redirectTo: '/' } ];
source share