【发布时间】:2014-06-20 21:38:28
【问题描述】:
这个 AngularJS 配置代码有什么问题?
(function () {
var ip = 'x.x.x.x';
var app = angular.module('cmal', ['controllers', 'directives', 'services', 'ngRoute'])
.constant("baseUrl", "http://" + ip + ":303/angular")
.config( function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider.when('/', { templateUrl: "index.html"});
$routeProvider.when('/users', { templateUrl: "users.html"});
$routeProvider.otherwise({template: "Sorry, the page you are trying to reach doesn't exist."});
});
})();
编辑:这不是斜线错误。这仍然对我不起作用,我在控制台中得到的只是“未捕获的对象”
编辑 2:好吧,我没有意识到您需要导入另一个 js 脚本来进行路由。但是现在我已经这样做了,我没有收到任何错误,但没有一条路线有效。
【问题讨论】:
-
到底是什么问题?乍一看表明您在常量定义中缺少端口号(303)和路径(角度)之间的 /...
-
仔细检查这个位:
303angular:) -
阅读我编辑的评论...
标签: javascript angularjs url-routing