在我的应用程序中,URLn中可以有n个参数,然后它也可以有一个可选的跟随模式。 例如,URL可以是
http://example.com/{param1}
http://example.com/{param1}/constant/{id}
http://example.com/{param1}/{param2}/constant/{id}
http://example.com/{param1}/{param2}
http://example.com/{param1}/{param2}/{param3}
http://example.com/{param1}/{param2}/{param3}/constant/{id}
等
如何为这类URL构建路由模块?
答案 0 :(得分:0)
RouterModule.forChild([
{ path: 'api/whatever/:id1/', component: ComponentName}
{ path: 'api/whatever/:id1/dosomething/:id2', component: ComponentName}
{ path: 'api/whatever/:id1/:id2', component: ComponentName}
{ path: 'api/whatever/:id1/:id2/dosomething/:id3/dosomemore', component: ComponentName}
])