Wildcard selector in the middle in Angular 2 route

2019-06-24 14:04发布

问题:

I am trying to develop a project with Angular.js 2. I am trying to use the router.

I am trying to create a route with parameters to catch things like following:

/m/SOMETHING1/c/SOME/THING2/p/SOMETHING3

Please note that SOME/THING2 is a string, that may include 0 or more / in it

What I need for Route Definition is something like: { path: "/m/:sth1Var/c/*sth2Var/p/:sth3Var", component: MultiPost, name: "RouteName" }

But I couldn't find a way to use wildcard character (*) in the middle.

Is the thing I am trying to achieve is possible without capturing all url and parsing whole thing myself?

回答1:

I don't think you can achieve that with routes definitions. You should move that out of the route into params or separate routes.