AngularJS - Route - 如何将星号(*)与路径匹配

Die*_*rin 9 javascript routes angularjs

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

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

有任何想法吗?

小智 14

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

when("/!/:resourceUrl*")
Run Code Online (Sandbox Code Playgroud)

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