小编Nat*_*ker的帖子

角度路由器'**'通配符作为带有子路由的全能?使用最新的2.4.0和路由器3.4.1

我一直在试验几十种配置试图让它工作,但无法解决这个问题.

给定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 …
Run Code Online (Sandbox Code Playgroud)

angular2-routing angular

7
推荐指数
1
解决办法
3247
查看次数

标签 统计

angular ×1

angular2-routing ×1