AngularJS路由提供者(.otherwise)

时间:2015-01-29 03:46:52

标签: angularjs

angular.module('app').config(appRte);

function appRte($routeProvider, $locationProvider, storiesURL) {
    $routeProvider.
        when('/', {
            templateUrl: 'stories.html',
            controller: 'StoryController as StoryCtrl',
            resolve: {
                storyDataPromiseObject: ['StoryData', function(StoryData) {
                    return StoryData.getStories(storiesURL);
                }]
            }
        })
        .otherwise({
            redirectTo: '/'
        });

    $locationProvider.html5Mode(true);
}

当我转到我的域根http://website.com/时,它工作正常,但如果我转到http://website.com/anything,我会收到错误消息。我希望网站重定向到/取而代之。这可能吗?

0 个答案:

没有答案