我的AngularJS重定向看起来像这样:
// create the module and name it asApp
var asApp = angular.module('asApp', ['ngRoute']);
// configure our routes
asApp.config(['$routeProvider', '$httpProvider', '$locationProvider', function($routeProvider, $httpProvider, $locationProvider) {
$routeProvider
// route for the home page
.when('/', {
title: 'Home of PeppyBurro – Radical Spanish learning tips and tricks for the adventurous learner',
templateUrl : 'pages/home.html',
controller : 'mainController'
})
// route for the about page
.when('/about', {
title: 'About PeppyBurro – Radical Spanish learning tips and tricks for the adventurous learner',
templateUrl : 'pages/about.html',
controller : 'mainController'
})
// route for the 404 page not found error
.when('/notfound', {
title: 'Page not found',
templateUrl : 'pages/404.html',
controller : 'mainController'
})
.otherwise('/notfound', {
title: 'Page not found',
templateUrl : 'pages/404.html',
controller : 'mainController'
})
}]);
Run Code Online (Sandbox Code Playgroud)
我需要的是,当在URL中输入未定义的slug时,脚本将我路由到404.html.因此,如果用户输入mysite.com/#/about,则应该向他显示该about.html页面.这个位工作正常.但是,当用户输入时mysite.com/#/abc,它应该向404.html我显示我在我.otherwise和.when('/notfound')指令中定义的页面.但是虽然.when('/notfound')位工作正常,但.otherwise不是.有什么我想念的吗?
| 归档时间: |
|
| 查看次数: |
1393 次 |
| 最近记录: |