I have angular universal app where part of routes is protected by CanActivate guard, where canActivate method use services to protect the route. But with initialNavigation: "enabled" config my guards didn't work. As I suppose, this issue is faced because of:
The initial navigation starts before the root component is created. The bootstrap is blocked until the initial navigation is complete. ( from angular docs )
The question is: how can I use services in canActivate guard with initialNavigation - enabled?
initialNavigationset toenabledin one of my projects and it did work - DavidcanActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { return this._statusService .userStatusObservable .pipe( map(status => { if(status.is_authenticated && status.is_customer) { return true; } else if(!status.is_authenticated) { setTimeout(() => this._router.navigate([])); return false; } } }) ); }and maybe it does not work because of The bootstrap is blocked until the initial navigation is complete. - Yuriy Kovaletsif( isPlatformBrowser(this._platformId) ) return nullthanks all for answering - Yuriy Kovalets