I have a problem with injection when I minify my angularJS project with grunt. To do a simple test, I tried to do the same thing with the sample we have after creating a angular project with the npm generator like this :
npm install -g generator-angular
yo angular
I add just a little things with bower. Here is my bower file :
{
"name": "angular-test",
"version": "0.0.0",
"dependencies": {
"angular": "1.2.15",
"json3": "~3.2.6",
"es5-shim": "~2.1.0",
"jquery": "~1.11.0",
"bootstrap": "~3.0.3",
"angular-route": "~1.2.15",
"angular-bootstrap": "~0.10.0",
"angular-sanitize": "~1.2.15",
"angular-cookies": "~1.2.15",
"angular-resource": "~1.2.15"
},
"devDependencies": {
"angular-mocks": "1.2.15",
"angular-scenario": "1.2.15"
},
"resolutions": {
"angular": "1.2.6"
}
}
Then I changed the app.js file like that :
'use strict';
angular
.module('angularTestApp', [
'ngCookies',
'ngResource',
'ngSanitize',
'ngRoute'
])
.config(['$routeProvider', '$httpProvider', function ($routeProvider, $httpProvider) {
$httpProvider.interceptors.push(function ($q) {
//We don't care about that ...
return {
'responseError': function (rejection) {
if(rejection.status === 401) {
console.log("Unauthorized page. Must redirect to ");
return;
}
return $q.reject(rejection);
}
};
});
}]);
If I lauch the "grunt serve" task everything is ok. But, if I do a "grunt build" and then try to access the index.html file through Apache for example, I have the following error :
Uncaught Error: [$injector:unpr] Unknown provider: aProvider <- a <- $http <- $compile
http://errors.angularjs.org/1.2.15/$injector/unpr?p0=aProvider%20%3C-%20a%20%3C-%20%24http%20%3C-%20%24compile
I read in few posts that I have to use the ngmin task to minify but it is already done in the sample yeoman project. Si How can I fix this please ?
Thank you very much
Clement