我想从ngRedux-store加载数据并对更改做出反应。我想在一个使用CanActivate接口的守卫中使用它。
通常我会像这样检索数据
@select(['auth', 'IsAuth']) isAuth : boolean;但我不能在我的看守课上用这个。我想我不得不做这样的事情。
console.warn('AuthGuard#canActivate called');
var d = this.ngRedux.select(['auth', 'IsAuth']);
console.error(d);我只得到了一个annonymusSubject。但是我想得到我的布尔值。
发布于 2018-02-13 20:13:03
这项工作
this.ngRedux.select(['auth', 'Header']).subscribe(m => {
this.Header = m;
});发布于 2018-01-10 22:40:33
可以使用take运算符从select中获取第一个值并完成可观察对象
canActivate(): Observable<boolean> {
// returns true/false from the store so canActivate
// can determine if the user can navigate to the route
return this.ngRedux.select(['auth', 'IsAuth'])
.take(1);
}https://stackoverflow.com/questions/48188643
复制相似问题