Wildcard selector in the middle in Angular 2 router

不羁岁月 提交于 2019-12-23 15:09:58

问题


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.



来源:https://stackoverflow.com/questions/34665124/wildcard-selector-in-the-middle-in-angular-2-router

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!