最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - AngularJS - Route - How to match star (*) as a path - Stack Overflow

programmeradmin7浏览0评论

I'm making a resource viewer app, but the problem is that i tried to match when("/!/:resourceUrl").

It works fine if the resource url is something like /path, but how can I make something like a /path/to/the/resource.
I don't know how much paths will it take, so I can't do .when("/!/:path1/:path2/:path3").

Any ideas?

I'm making a resource viewer app, but the problem is that i tried to match when("/!/:resourceUrl").

It works fine if the resource url is something like /path, but how can I make something like a /path/to/the/resource.
I don't know how much paths will it take, so I can't do .when("/!/:path1/:path2/:path3").

Any ideas?

Share Improve this question asked Oct 2, 2012 at 5:43 DiestrinDiestrin 2941 gold badge4 silver badges11 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 15

As of angular-1.2 you can do this:

when("/!/:resourceUrl*")

http://code.angularjs/1.2.0/docs/api/ngRoute.$routeProvider

In particular the documentation gives the following example:

For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode /code/with/slashs/edit and extract:

  • color: brown
  • largecode: code/with/slashs

As of now, AngularJS doesn't support regular expressions in routes.

Check these links: https://github./angular/angular.js/issues/918, https://github./angular/angular.js/pull/972

发布评论

评论列表(0)

  1. 暂无评论