Angular 带NGRX的角度保护装置
我正在尝试将AuthGuard与NGRX一起使用,但我总是在这条路线上未定义: 当我看商店时,estaAutenticado是正确的,但我不能准时到达,因为它是异步的 我的卫兵:Angular 带NGRX的角度保护装置,angular,authentication,store,ngrx,Angular,Authentication,Store,Ngrx,我正在尝试将AuthGuard与NGRX一起使用,但我总是在这条路线上未定义: 当我看商店时,estaAutenticado是正确的,但我不能准时到达,因为它是异步的 我的卫兵: return this.store.pipe( select(fromAuth.getEstaAutenticado ), map(authed => { console.log(authed) // <---- Always return undefin
return this.store.pipe(
select(fromAuth.getEstaAutenticado ),
map(authed => {
console.log(authed) // <---- Always return undefined
if (!authed) {
this.router.navigate(['/'])
return false;
}
return true;
})
);
}
```
// Reducer
解决了,我缺少选择器功能
export const selecionaState = createFeatureSelector<State>('autenticacao');
export const seleconastate=createFeatureSelector('autenticacao');
尝试添加过滤器(authed=>typeof authed!==“undefined”)
在地图之前createReducer
code?@SWilko哪个部分?@PrzemyslawJanBeigert我得到了相同的结果,动作被调度我得到了登录成功,但我仍然收到了undefined。
export const selecionaState = createFeatureSelector<State>('autenticacao');