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

$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' );
然后是几种状态:
$stateProvider
    .state('about',
        {
            "url":          "/about",
            "templateUrl":  "about.tmpl"
        }
    )
    //…
我尝试打index.html#/index.html#/about,但没有任何状态被调用(随后没有任何 Controller 被调用)。但是遵守我的路线(例如,“”被重定向到“/ about”)。没有控制台错误,也不会按预期返回值(例如index.html#/about,$ match和path = /about)。
编辑
看来Require是问题的一部分:
  • Here它可以在jsfiddle中运行,而不需要。
  • Here在使用require的插件中不起作用。
  • 最佳答案

    原来我是个白痴:当我从ngRouter切换到ui.router时,我忘记了将ng-view切换为ui-view。工作插件:http://plnkr.co/edit/ZckIBlayuB10hooJ0sY5

    10-07 19:09
    查看更多