5
請考慮以下來自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"];
}
})
});
執行Python 3的SimpleHttpServer,我得到一個404 error
試圖訪問時:http://localhost:8000/state1234324324
。
爲什麼沒有$urlRouterProvider.otherwise("/state1");
重新定向所有未知的路線/state1
,其每本question,先後與/state1
URL相關聯的規定state
?
爲什麼這不適用於ui路由器?我的路線不工作,因爲我補充說,修復,雖然否則現在工作... –