I have an AuthGuard (used for routing) that implements CanActivate.
canActivate() {
return this.loginService.isLoggedIn();
}
My problem is, that the CanActivate-result depends on a http-get-result - the LoginService returns an Observable.
isLoggedIn():Observable<boolean> {
return this.http.get(ApiResources.LOGON).map(response => response.ok);
}
How can i bring those together - make CanActivate depend on a backend state?
# # # # # #
EDIT: Please note, that this question is from 2016 - a very early stage of angular/router has been used.
canActivate()can return anObservable, just make sure that theObservablehas completed (ie.observer.complete()). - Philip Bulleytake(1)Rx operator to achieve the completnes of stream, What if I forget to add it? - Felix