我有一个实现CanActivate的AuthGuard(用于路由).
canActivate() {
return this.loginService.isLoggedIn();
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,CanActivate结果依赖于http-get-result - LoginService返回一个Observable.
isLoggedIn():Observable<boolean> {
return this.http.get(ApiResources.LOGON).map(response => response.ok);
}
Run Code Online (Sandbox Code Playgroud)
我如何将它们结合在一起 - 使CanActivate依赖于后端状态?