我正在制作一个资源查看器应用程序,但问题是我试图匹配 when("/!/:resourceUrl").

如果资源 url 是这样的,它就可以正常工作 /path, ,但是我怎样才能做出类似的东西 /path/to/the/resource.
我不知道要走多少路,所以我做不到 .when("/!/:path1/:path2/:path3").

有任何想法吗?

有帮助吗?

解决方案

从 angular-1.2 开始,你可以这样做:

when("/!/:resourceUrl*")

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

该文档特别给出了以下示例:

例如,类似的路线 /color/:color/largecode/:largecode*\/edit 将匹配 /color/brown/largecode /code/with/slashs/edit 并提取:

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

其他提示

截至目前,AngularJS 不支持路由中的正则表达式。

检查这些链接: https://github.com/angular/angular.js/issues/918, https://github.com/angular/angular.js/pull/972

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top