【发布时间】:2020-05-03 06:41:16
【问题描述】:
我目前为我的 Angular 应用准备了这些 routes。
const routes: Routes = [
{ path: '', component: DashboardComponent },
{ path: 'login', component: LoginComponent },
{ path: 'upload', component: UploadPictureComponent, canActivate: [AngularFireAuthGuard] },
{ path: 'view', component: ListPictureComponent, canActivate: [AngularFireAuthGuard] },
{ path: '**', component: NotFoundComponent },
];
当前行为:
如果用户未登录并转到路由upload 或view,他们的路由将被阻止并且不会看到任何内容。
期望的行为:
如果用户转到任何被阻止的路线,我想向他们显示NotFoundComponent。
我无法解决的问题是,当路由被守卫拒绝时,Angular 会取消路由事件。
【问题讨论】:
标签: angular typescript