Nat*_*ker 7 angular2-routing angular
我一直在试验几十种配置试图让它工作,但无法解决这个问题.
给定URL如下:
anything并且otherthing几乎可以是任何东西.
我希望路由配置可以工作,但最终接管定义的路由,https: //domain.com/profile会触发catchall('**'),这似乎很奇怪,因为根据我的理解,catchall应该只会触发或捕获上面未定义的路线:
这在哪里app.module:
export const routes = [
{
path: '',
loadChildren: 'app/dashboard/dashboard.module'
},
{
path: 'profile',
loadChildren: 'app/profile/profile.module'
},
{
path: '**',
loadChildren: 'app/anything/anything.module'
}
];
@NgModule({
imports: [
BrowserModule,
RouterModule.forRoot(routes)
],
declarations: [AppComponent]
bootstrap: [AppComponent]
})
export class AppModule {}
Run Code Online (Sandbox Code Playgroud)
这在哪里anything.module:
const routes = [
{
path: ':id', // hoping to pick up the wildcard as param this way
component: AnyComponent,
children: [
{
path: 'edit',
component: EditComponent
}
]
}
];
@NgModule({
imports: [
CommonModule,
RouterModule.forChild(routes)
],
declarations: [
AnyComponent,
EditComponent
]
})
export default class AnythingModule {}
Run Code Online (Sandbox Code Playgroud)
反正是否使上述用例与Angular Router 3.4.1一起工作?
| 归档时间: |
|
| 查看次数: |
3247 次 |
| 最近记录: |