【问题标题】:angular 9 why canActivateChild start befor canActivate completed?角度 9 为什么 canActivateChild 在 canActivate 完成之前启动?
【发布时间】:2022-01-05 12:39:34
【问题描述】:

在我的程序中,我在 canActivateChild 中有一个需要发生的函数 canActivate完成后,子组件在父组件的canActivate完成之前加载,为什么?

my routing-module:
const routes: Routes = [

    {
    path: '',
    component: MainComponent,
    canActivate: [LoadDataGuard, ConfigureJsGuard],
    canActivateChild: [EnterChildGuard],
    canDeactivate: [CleanupJsGuard],
    data: {
        modelService: ModelService,
     
    } ,
    children: [
        {
            component: ChildComponent,
         .......

【问题讨论】:

    标签: angular observable angular-routing canactivate canactivatechild


    【解决方案1】:

    你可以将canActivateChild添加到主路由的空路径子

    喜欢

    {
    path: '',
    component: MainComponent,
    canActivate: [LoadDataGuard, ConfigureJsGuard],
    canDeactivate: [CleanupJsGuard],
    data: {
        modelService: ModelService,
     
    } ,
    children: [
        path: '',
        canActivateChild: [EnterChildGuard],
        children: [
        {
            component: ChildComponent,
          .......
          },
        ]
    

    【讨论】:

      猜你喜欢
      • 2017-07-26
      • 1970-01-01
      • 2015-09-02
      • 2019-12-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多