l'interface utilisateur du routeur $urlRouterProvider.sinon avec Mode HTML5

Envisager légèrement modifié le code de l'interface utilisateur du routeur 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"];
            }
        })
});

Lancer python 3 SimpleHttpServer, je reçois un 404 error lorsque vous tentez d'accéder: http://localhost:8000/state1234324324.

Pourquoi ne pas $urlRouterProvider.otherwise("/state1"); re-diriger tous inconnu routes à /state1, qui par ce question, a défini un state associés à la /state1 url?

OriginalL'auteur Kevin Meredith | 2014-06-06