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

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一起工作?

Gün*_*uer 0

如果ProfileModule没有path: ''路由,则没有可匹配的路由,路由器将继续匹配剩余的路由。