【发布时间】:2021-04-09 02:05:34
【问题描述】:
如果未满足特定条件,我希望不显示Mat Dialog。我曾希望使用 Angular Guard,但似乎没有与组件关联的路由(除了调用它的总体网页)。
[因此,我曾希望它属于canActivateChild - 但这阻止了整个页面的加载。 ]
我已经回滚了我的示例,只是试图阻止基于 FeedBackGuard 组件(现在只返回 false)访问特定组件('give-feedback')。
反馈组件由页面/example 上的函数调用。我尝试过设置 canActivate(针对组件)、canActivateChild(作为example 页面的子集)、设置 canLoad 以及其中的多个变体。
到目前为止,我只成功阻止了 example 的加载,但没有成功阻止为 give-feedback 启动的 Mat Dialog
目前app-routing.module.ts中的配置是:
{path: 'Example', component: ExampleComponent,
canActivateChild : [FeedbackGuard],
children: [
{ path: 'feedback-example', component: MatDialog },
{ path: 'feedback-example', component: GiveFeedbackComponent }
]
},
【问题讨论】:
标签: angular angular-router-guards