问题描述:

I'm currently working on a webapp project, and I needed to add a new factory. But when I want to inject the factory in a controller (in the same module) I get the error in the title.

Here's my code :

The Commande factory (commande.service.js)

(function() {

'use strict';

angular

.module('myApp')

.factory('Commande', Commande)

Commande.$inject = ['$resource', 'DateUtils'];

function Commande ($resource, DateUtils) {

var resourceUrl1 = 'url1';

var resourceUrl2 = 'url2';

return {

byNumero : $resource(resourceUrl1, {}, {

'query': { method: 'GET', isArray: true},

'get': {

method: 'GET',

transformResponse: function (data) {

if(data){

data = angular.fromJson(data);

}

return data;

}

}

}),

byNomMarcheAndNumero : $resource(resourceUrl2, {}, {

'query': { method: 'GET', isArray: true},

'get': {

method: 'GET',

transformResponse: function (data) {

if(data){

data = angular.fromJson(data);

}

return data;

}

}

})

}

};})()

The PanelCommande controller (panelCommande.controller.js)

(function() {

'use strict';

angular

.module('myApp')

.controller('PanelCommandeController', PanelCommandeController);

PanelCommandeController.$inject = ['$scope', 'Commande', '$rootScope', 'Prestation'];

function PanelCommandeController($scope, Commande, $rootScope, Prestation) {

//A lot of stuff

}})();

Prestation is another factory that has the same structure as Commande, and it works fine.

I have this error message :

Error: [$injector:unpr] Unknown provider: CommandeProvider <- Commande <- PanelRepartitionProductionController <- PanelCommandeController

Does somebody see where is the problem?

Thank you.

相关阅读:
Top