我在我的角度路由器中包含了runGuardsAndResolvers:'always',它可以正常工作:
const APP_ROUTES: Routes = [
{
path: '',
canDeactivate: [DeActivateGuard],
canActivate: [ActivateGuard],
runGuardsAndResolvers: 'always',
children: [
{
path: '',
redirectTo: '/mainApp',
pathMatch: 'full'
},
{
path: 'route1',
canActivate: [Route1Guard],
loadChildren: 'app/route1/route1.module#Route1Module',
},
{
path: 'route2',
canActivate: [Route2Guard],
loadChildren: 'app/route2/route2.module#Route1Module',
}
]
}]
但是我要一直运行的唯一警卫是常规路由的canDeactivate,现在每个路由更改都运行ActivateGuard和RouteXGuard。
是否可以使用runGuardsAndResolvers选择要运行的守护程序?