0

In my application, there can be n number of params in the URLn and then it can have an optional following pattern too. For example, the URLs can be

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}

etc

How do I construct my routing module for these kind of URLs?

user1532043
  • 859
  • 2
  • 15
  • 26

1 Answers1

0

do you mean like so?

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}
])
Wesley Coetzee
  • 4,768
  • 3
  • 27
  • 45
  • Something like that, yes. But :id1/:id2 are not always just :id1/:id2, it may be :id1/:id2/:id3/..../idn – user1532043 Apr 06 '17 at 12:38
  • So you want to be able to specify an indefinite amount of ids? This wouldn't be possible from what I know. You'd need to specify each route as per my example I'm afraid. I'm not too sure what you're trying to achieve by this, if you give me an example I can maybe suggest an alternative way? – Wesley Coetzee Apr 06 '17 at 15:26