angular ui路由器的示例演示具有此开始页面的链接:
'ui-router'的完整网址是/或 http://angular-ui.github.io/ui-router/sample/#/
'about'的完整网址是/about或http://angular-ui.github.io/ui-router/sample/#/about
当我使用durandalJS时,有一个限制,默认网址只是"/",可能没有"/ ui-router".
角度ui路由器插件有相同的限制吗?
请考虑ui-router的wiki中的以下略微修改的代码.
var myApp = angular.module('myApp',['ui.router']);
myApp.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
// for any unmatched url
$urlRouterProvider.otherwise("/state1");
$locationProvider.html5Mode(true);
// now set up the states
$stateProvider
.state('state1', {
url: '/state1',
templateUrl: "partials/state1.html"
})
.state('state1.list', {
url: "/list",
templateUrl: "partials/state1.list.html",
controller: function($scope) {
$scope.items = ["A", "List", "of", "Items"];
}
})
.state('state2', {
url: "/state2",
templateUrl: "partials/state2.list.html",
controller: function($scope) {
$scope.things = ["a", "set", "of", "things"];
}
})
});
Run Code Online (Sandbox Code Playgroud)
运行python 3的SimpleHttpServer,我404 error在尝试访问时得到:http://localhost:8000/state1234324324.
为什么没有$urlRouterProvider.otherwise("/state1");重定向所有未知路由/state1,根据这个问题,已经定义state …