我使用棱角1.5.3但是当我注射" ngRoute"我得到这样的错误:
angular.js:38未捕获错误:[$ injector:modulerr] http://errors.angularjs.org/1.5.3/ $ injector / modulerr?p0 = scotchApp& p1 =错误%... ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.3%2Fangular .min.js%3A20%3A463)(匿名函数)@ angular.js:38(匿名函数)@ angular.js:4547q @ angular.js:321g @ angular.js:4508eb @ angular.js:4430c @ angular。 js:1710yc @ angular.js:1731de @ angular.js:1616(匿名函数)@ angular.js:30709b @ angular.js:3127Pf @ angular.js:3417Of.d @ angular.js:3405
这是代码
var scotchApp = angular.module('scotchApp', ['ngRoute']);
scotchApp.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl : 'home.html',
controller : 'mainController'
})
.when('/about', {
templateUrl : 'about.html',
controller : 'aboutController'
})
.when('/contact', {
templateUrl : 'contact.html',
controller : 'contactController'
});
});
scotchApp.controller('mainController', function($scope) {
// create a message to display in our view
$scope.message = 'Everyone come and see how good I look!';
});
scotchApp.controller('aboutController', function($scope) {
$scope.message = 'Look! I am an about page.';
});
scotchApp.controller('contactController', function($scope) {
$scope.message = 'Contact us! JK. This is just a demo.';
});
</script>
</head>
<body ng-controller="mainController">
<div id="main">
<div ng-view></div>
</div>
</body>
</html>
请帮我解决一下
由于
答案 0 :(得分:0)
模块ngRoute
不在主角度脚本中。它位于angular-route.js
。确保在页面中包含此脚本。
<script src="angular.js">
<script src="angular-route.js">
根据1.5.3的docs:
您可以从以下位置下载此文件:
- Google CDN 例如
//ajax.googleapis.com/ajax/libs/angularjs/X.Y.Z/angular-route.js
- Bower例如
bower install angular-route@X.Y.Z
- code.angularjs.org例如
"//code.angularjs.org/X.Y.Z/angular-route.js"
其中X.Y.Z是您正在运行的AngularJS版本。
有关详情,请参阅ngRoute
process_item()
。