Uncaught Error: [$injector:modulerr] in angular js
Uncaught Error: [$injector:modulerr] in angular js
我收到错误未捕获错误:[$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)
在 Object.e [作为调用] (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)
在 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
将 $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。
希望能解决您的问题。
我收到错误未捕获错误:[$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) 在 Object.e [作为调用] (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) 在 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
将 $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。
希望能解决您的问题。