Angular 2 Guards: canLoad() Is Firing Twice any Reason? -


canload firing twice on rejection or in acceptance

export const routes: routes = [     {         path: 'inbox',         canload: [canactivateviaauthguardservice],         loadchildren: 'lazyloaded module',     } ] 

canload implementation

canload(route: route): observable<boolean> {     console.log("canload called?");      return this._apsm.ismodulecanbeloaded()       .map(       res => {         console.log(res);          if (res === false) {           // user:don't has access           this.router.navigatebyurl('/error');            return false;         }          // user has access:         return true;       })       .catch((error: any) => {         console.log(error);         this.router.navigatebyurl('/error');         return observable.of(false);       });       } 

servie method invoked

assuming observale boolean response returned

ismodulecanbeloaded(): observable<boolean> {              return false observable<boolean>; } 


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -