我收到错误未捕获错误:[$ injector:modulerr]
我已经包含了以下js文件
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-resource.min.js"></script>
<script src="lib/jquery-1.12.1.min.js"></script>
我的js代码是
angular.module('website',['ngRoute','ngResource']).
config(function($routerProvider){
$routerProvider.
when('/about',{template:'templates/about.html'}),
when('/careers',{template:'templates/careers.html'}),
when('/signup',{template:'templates/signup.html'}),
otherwise({redirectTo : '/home', template:'/home.html'})
})
function mainController($scope){
}
有人请帮助我,我失踪的地方。
编辑: 错误日志是 由于以下原因无法实例化模块网站: 错误:[$ injector:unpr] http://errors.angularjs.org/1.4.5/ $ injector / unpr?p0 =%24ro ... 在错误(本机) 在https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:6:416 在https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:40:307 在d(https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:38:308) at Object.e [as invoke](https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:39:64) 在d(https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:37:279) 在https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:37:403 在n(https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:7:322) at g(https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:37:180) 在eb(https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js:40:435
答案 0 :(得分:3)
将$routerProvider
更改为$routeProvider
。在配置中将,
替换为.
。例如:
when('/about',{template:'templates/about.html'}),
when('/careers',{template:'templates/careers.html'})
到
when('/about',{template:'templates/about.html'})
.when('/careers',{template:'templates/careers.html'})
您的JavaScript代码应如下所示:
var website = angular.module('website',['ngRoute','ngResource']);
website.config(function($routeProvider){
$routeProvider.
when('/about',{template:'templates/about.html'})
.when('/careers',{template:'templates/careers.html'})
.when('/signup',{template:'templates/signup.html'})
.otherwise({redirectTo : '/home', template:'/home.html'})
})
website.controller('mainController', function($scope){
});
有关详细信息,请please have a look at this example。
希望能解决你的问题。