0

ユーザーがアクセスできるアプリケーションの部分を決定する BE からの許可 DTO があります。NgRx セレクターを使用して、CanLoad ガード内で使用したいのですが、動作させることができません。

routes.ts

{
  path: 'acquisition',
  canLoad: [AcquisitionGuard],
  loadChildren: () => import('./acquisition/acquisition.module').then(m => m.AcquisitionModule),
  pathMatch: 'full',
},

警備員:

canLoad(route: Route, segments: UrlSegment[]): Observable<boolean> | Promise<boolean> | boolean {
  console.log('canLoad guard'); //never fires
  return this.store.select(fromPermission.canAcess);
}

console.log何らかの理由で、このガードは起動しません (とで試しましたdebugger)。に変更しcanActiveて「親」ルートファイルで実行すると、どちらも起動しません。起動するのは、変更しcanActiveて「子」routes.fileに移動したときだけです

Acquisition.routes.ts

{
  path: 'acquisition',
  canActive: [AcquisitionGuard], //This is the only time I'll get some response from the guard
  component: AcquisitionComponent,
  children: [...],
},

編集: これは、モジュールがロードされると「CanLoad」ガードが再度起動されないという事実が原因のようです。Electron がすべてを一度にロードする可能性があるため、このガードを呼び出すことはできませんか?

4

1 に答える 1