通配符*命名组(:名称*)不能含有$ routeProvider角JS 1.0.6工作通配符、名称、工作、routeProvider

由网友(执笔画倾城)分享简介:我想通过以下code片段做在角的JS通配符(*)路由:I am trying to do a wildcard (*) routing in Angular js through following code snippet:$routeProvider.when('/something/:action/:id/:...

我想通过以下code片段做在角的JS通配符(*)路由:

I am trying to do a wildcard (*) routing in Angular js through following code snippet:

$routeProvider.when('/something/:action/:id/:params*/', {

  templateUrl : "/js/angular/views/sample/index.html",

  controller : 'SampleCtrl'

}).otherwise({

  redirectTo: '/something/all' //This exists in real code

});

样本路径:/#/事/信息/ 201/1

在调用这个网址就执行,否则方法。我在做什么错在这里?在此先感谢

On calling this url it executes the otherwise method. What am I doing wrong here? Thanks in advance

推荐答案

$ routeProvider 不支持标准的正则表达式,但它支持的命名组:

The $routeProvider does not support standard regexp but it does support named groups:

  

路径可以包含开始用冒号命名组(:名称)。所有字符,直到达到下一个斜线都以给定名字匹配,并存储在$ routeParams当路线匹配

path can contain named groups starting with a colon (:name). All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches.

路径可以包含开头的星号(*名)命名组。所有字符都急切地存储在$ routeParams以给定名字的时候路由匹配。

path can contain named groups starting with a star (*name). All characters are eagerly stored in $routeParams under the given name when the route matches.

所以,你应该尝试

$ routeProvider.when('/事/:动作/:ID /:PARAMS / *休息'

将匹配 /#/事/信息/ 201/1 /不管/你/说

阅读全文

相关推荐

最新文章