我到处搜索,只能找到访问 ngrx 存储的路由防护的已弃用的基于类的 Canactivate 实现。
有人可以提供一个访问 ngrx 存储的功能路由防护的示例吗?
实施方式是相同的。 唯一的区别是,您不使用构造函数注入存储,而是使用 Angular 提供的新
inject
方法。
export function myRouterGuard(): Observable<boolean|UrlTree> {
const store = inject(Store);
// implementation comes here
}