angular-ui:ui-router动态路由和状态

jac*_*cob 2 javascript requirejs angularjs angular-ui angular-ui-router

我有一个动态路由定义为:

$urlRouterProvider
    .when(
        '/:resource?collection&type&id',
        [
            '$match', '$stateParams',
            function routeValidator( $match , $stateParams )
            {
                var path = '';
                angular.forEach($match, function joinner( val , key )
                {
                    if ( angular.isDefined(val) ) path += '/' + val;
                });
                return path;
            }
        ]
    )
    .when( '' , '/about' )
    .when( '/' , '/about' )
    .otherwise( '/404' );
Run Code Online (Sandbox Code Playgroud)

然后是几个州:

$stateProvider
    .state('about',
        {
            "url":          "/about",
            "templateUrl":  "about.tmpl"
        }
    )
    //…
Run Code Online (Sandbox Code Playgroud)

我尝试点击index.html#/或者index.html#/about,我的状态都没有被调用(后来没有我的控制器).但是我的路线被遵守(前''被重定向到'/ about').没有控制台错误和值按预期返回(例如index.html#/about,$ match&path = /about).

编辑

似乎需求是问题的一部分:

  • 这里它在没有要求的jsfiddle中工作.
  • 在这里不是在plunker工作与要求.

jac*_*cob 9

转过来我是个白痴:当我从ngRouter切换到ui.router时,我忘记切换ng-viewui-view.工作人员:http://plnkr.co/edit/ZckIBlayuB10hooJ0sY5