我用角1.5.3,但是當我注入「ngRoute」我得到的錯誤是這樣的:錯誤時注入ngRoute
angular.js:38Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.5.3/ $injector/modulerr?p0=scotchApp&p1=Error%…ogleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.5.3%2Fangular.min.js%3A20%3A463)(anonymous function) @ angular.js:38(anonymous function) @ angular.js:4547q @ angular.js:321g @ angular.js:4508eb @ angular.js:4430c @ angular.js:1710yc @ angular.js:1731de @ angular.js:1616(anonymous function) @ 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>
請幫我解決這個問題
謝謝
您是否已將'angular-route.js'添加到index.html文件中,並且順序正確? – M22an
也使用angular.js的unminified版本有助於調試 – jithin