相关疑难解决方法(0)

Angular 2 - Routing - CanActivate使用Observable

我有一个实现CanActivateAuthGuard(用于路由).

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依赖于后端状态?

angular2-routing angular2-http angular

75
推荐指数
3
解决办法
6万
查看次数

标签 统计

angular ×1

angular2-http ×1

angular2-routing ×1