【发布时间】:2018-03-08 02:53:29
【问题描述】:
如果 Angular 应用有两个模块:AppModule 和 ProfileModule,它们可以配置自己的路由。
在this 指南中,它说路由配置的顺序很重要。举个例子:
const appRoutes: Routes = [
{ path: 'crisis-center', component: CrisisListComponent },
{ path: 'hero/:id', component: HeroDetailComponent },
{
path: 'heroes',
component: HeroListComponent,
data: { title: 'Heroes List' }
},
{ path: '',
redirectTo: '/heroes',
pathMatch: 'full'
},
{ path: '**', component: PageNotFoundComponent }
];
这里首先评估crisis-center 路径,最后评估** 路径。
但是,如果AppModule 和ProfileModule 配置了自己的路由,则不清楚特定路由的评估是如何发生的。如果AppModule 路由配置最后有一个** 路由,如上述配置,这将匹配与AppModule 中的其他路由不匹配的所有路由。这将使ProfileModule 的路由配置无用。
那么,当有多个模块具有自己的路由配置时,路由的优先级如何工作?
【问题讨论】:
标签: angular