【发布时间】:2015-06-07 19:27:00
【问题描述】:
我的app.js 中有以下代码。
var app = angular.module("TacoTime", ['ngRoute']);
app.config(['$routeProvider',
function($routeProvider) {
$routeProvider
// route for the home page
.when('/', {
templateUrl : 'views/home.html',
controller : 'HomeController'
})
// route for the directions page
.when('/list', {
templateUrl : 'views/list.html',
controller : 'ListController'
})
.otherwise({
redirectTo: '/'
});
}]);
当我有普通的/ 时,我会去home.html。当我尝试/lists 时,我收到一条错误消息,提示Nothing 与给定的URI 匹配。
我一直在想我做错了什么。
【问题讨论】:
-
你使用的是html5mode吗?如果没有,请确保您使用的是 url '#/' 和 '#/list'
-
在我最初的评论中添加更多内容,您的路线是
/list,您说当您尝试/lists时出现错误... -
罗尼 - /list。打错字了,抱歉。我不认为我正在使用 html5mode
-
Nicholas - 当我在浏览器中输入 /#/list 时,它起作用了!谢谢!
标签: angularjs url-routing ngroute