[英]Uncaught Error: [$injector:modulerr] AngularJS
First of all, I would like to say that i really didn't want to ask this question, but after two hours of not understanding the reason of it, it now decide to ask for some help. 首先,我想说的是我真的不想问这个问题,但是在两个小时不了解它的原因之后,它现在决定寻求帮助。
I want to add the ngResource module in my app. 我想在我的应用程序中添加ngResource模块。 Before doing it, everything worked well. 在这样做之前,一切都很好。
So I create my app like this : 所以我这样创建我的应用程序:
var app = angular.module('app', [ 'ngResource', 'ngRoute' ]);
then i config it like this : 然后我像这样配置它:
app.config(
[
'$resourceProvider',
'$routeProvider',
'$locationProvider',
function ($resourceProvider, $routeProvider, $locationProvider ) {
$resourceProvider.defaults.stripTrailingSlashes = false;
$locationProvider.html5Mode(false);
$routeProvider.when('/', {
templateUrl: 'templates/home.html',
controller: 'homeController'
}).when('/404', {
templateUrl: 'templates/404.html'
}).otherwise({
redirectTo: '/404'
});
}
]);
And i get this error which means : 我得到这个错误,这意味着:
Failed to instantiate module app due to:
TypeError: Cannot set property 'stripTrailingSlashes' of undefined
at http://localhost:3000/js/app.js:14
This error occurs when a module fails to load due to some exception. The error message above should provide additional context.
line 14 is of course : 第14行当然是:
$resourceProvider.defaults.stripTrailingSlashes = false;
The angular-resource.js is well loaded and before app.js. angular-resource.js加载良好,位于app.js之前。
I don't understand, I did it exactly like it's said on the Angular Doc :( 我不明白,我完全按照Angular Doc上的说做了:(
I hope my question isn't completely stupid and the reason is not obvious cause I really don't see where I am wrong! 我希望我的问题不是完全愚蠢,原因也不明显,因为我真的看不到哪里错了!
Thank you if you can help me ! 谢谢你能帮我!
Bastien 巴斯蒂安
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.