Angular 从入坑到挖坑 - 路由守卫连连看 (5)

同样的,针对路由守卫的实现完成后,将需要使用到的路由守卫添加到 crisis-center 路由的 canLoad 数组中即可实现授权认证不通过时不加载模块

import { HeroCanDeactivateGuard } from './hero-list/guards/hero-can-deactivate.guard'; import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; const routes: Routes = [ { path: 'crisis-center', loadChildren: () => import('./crisis/crisis.module').then(m => m.CrisisModule) } ]; @NgModule({ imports: [RouterModule.forRoot(routes, { enableTracing: true })], exports: [RouterModule], }) export class AppRoutingModule { }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wspggy.html