Looking at this authguard which is called from canactivate :
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private loginServicePOST:LoginService, private router:Router) { }
canActivate(next:ActivatedRouteSnapshot, state:RouterStateSnapshot) {
return this.loginServicePOST({...}).map(e => {
if (e) {
return true;
}
}).catch(() => {
return Observable.of(false);
});
}
}
This code is working and an http request is invoked to server.
Question :
This is a cold observable and no one .subscribes to it - so I don't understand how this post request is invoked and why.
subscribe must be written IMHO.
NB
I already know that canactivate can return bool/Promise<bool>/Observable<bool>
The router is subscribing to the observable returned by
canActivatewhich invokes the observable returned byloginService(...).map(...)