Hello:

 I'm trying to code a custom provider in angular but, when it is injected 
in a controller, I get this error:

   Error: [$injector:unpr] 
http://errors.angularjs.org/1.3.0-rc.2/$injector/unpr?p0=profileProvider%20%3C-%20profile%20%3C-%20thinLogger

 I know that this error means that angular can not find the provider 
thinLogger in the module but, the funny thing is that, when I do a debug of 
my code I see the provider inside of the module

<https://lh3.googleusercontent.com/-077Gwbst460/VBm5jAphjcI/AAAAAAAABe8/VT2v9ioEO2Q/s1600/Error%2Bprovider.png>
This is the code of my provider:

thinModule = angular.module('thinModule',['thinConfiguration']);

thinModule.value("thinProfile","THDEV");

if (thinModule){
 thinModule.provider('thinLogger',function thinLoggerProvider () {
 function createLogger (name, level) {
var logger = new Log4js.getLogger(name);
logger.setLevel(level);
 return logger;
}
 function getAjaxAppender (url, threshold){
var ajaxAppender = new AjaxAppender(url);
ajaxAppender.setThreshold(threshold);
ajaxAppender.setLayout(Log4js.JSONLayout());
 return ajaxAppender;
}
 function getConsoleAppender (inline){
var consoleAppender = new ConsoleAppender(inline);
 return consoleAppender;
 }
 this.$get = ['profile','$injector',function createLogger 
(profile,$injector){
var loggers=null;
 if (profile.indexOf("TH") == 0){
var properties = $injector.get(profile).logger;
 for (var i=0; i < properties.length; i++){
if (!loggers[properties[i].name]){
loggers[properties[i].name] = createLogger(properties[i].name, 
properties[i].loggerLevel);
 if (properties[i].AjaxAppender){
loggers[properties[i].name].addAppender(getAjaxAppender(properties[i].AjaxAppender.URL,
 
properties[i].AjaxAppender.thresHold));
} else if (properties[i].ConsoleAppender){
loggers[properties[i].name].addAppender(getConsoleAppender(properties[i].ConsoleAppender.inline));
} else {
delete loggers[properties[i].name];
throw "There is not appender defined for this logger";
}
} else {
throw "There are two or more loggers with the same name";
}
}
 } else {
throw "Invalid profile. You have tried to start the architecture's core 
with an invalid configuration";
}
 return loggers;
 }];
 });
} else {
throw ("Error: Main module could not  be found");
}

This is the code of the controller:
var opListControllers = angular.module('opListControllers', ['thinModule']);

opListControllers.controller('OpsListCtrl', ['$scope', 
'$http','OportunidadSrv','thinLogger',
   function ($scope, $http,OportunidadSrv,thinLogger) {
 var loggers = thinLogger();
 if (!loggers.thinLogger1){
console.log("Error: No existe el thinLogger1");
} else {
console.log("El thinLogger1 existe");
 loggers.thinLogger1.trace("NNN Prueba 1 de log");
 loggers.thinLogger1.debug("NNN Prueba 2 de log");
}
 if (!loggers.thinLogger2){
console.log("Error: No existen el thinLogger2");
} else {
console.log("El thinLogger2 existe");
 loggers.thinLogger2.debug("NNN Prueba de log 3");
 loggers.thinLogger2.error("NNN Prueba de log 4");
}
 if(!loggers.thinLogger3){
conosole.log("Por ahora, el thinLogger3 no tiene que existir");
} else {
console.log("Error: El thinLogger3 existe cuando no deberia");
}
 OportunidadSrv.getAll().then(function(data) {       
$scope.oportunidades = data.data.response;       
   });
$scope.range = function(opsFiltradas) {

$scope.opsFiltradas = opsFiltradas;

var botones = [];
var nbotones = Math.ceil((  opsFiltradas - $scope.opsToView) / 
$scope.opsToView) + 1;

for (var i = 0; i <= nbotones; i++) {
botones.push(i);
}

return botones;
};

$scope.newField = {};
$scope.editing = false;

$scope.getPage = function(a) {
$scope.pagina = a; 
};
$scope.setInitPage = function() {
$scope.pagina = 0;
};
$scope.classOpPag = function(i) {
var clase;
clase = "vis_" + ( i < ($scope.opsToView + ($scope.opsToView * 
$scope.pagina)) && (i >= ($scope.opsToView * $scope.pagina)));
return clase;
};
$scope.pagina = 0;
 $scope.editAppKey = function(field) {
    $scope.editing = $scope.oportunidades.indexOf(field);
    $scope.newField = angular.copy(field);
};

$scope.saveField = function(field) {
$scope.update(field);
};

$scope.cancel = function(index) {
    if ($scope.editing !== false) {
        $scope.oportunidades[$scope.editing] = $scope.newField;
        $scope.editing = false;
    }       
};
 $scope.update = function(field) {
OportunidadSrv.save(field);
};

}]);

opListControllers.controller('OpsDetailCtrl', ['$scope', 
'$routeParams','$http','OportunidadSrv',
  function($scope, $routeParams,$http,OportunidadSrv) { 
OportunidadSrv.getOp($routeParams.opId).then(function(data) {       
$scope.op = data.data.response;
$scope.op.fechaModificacion=new Date($scope.op.fechaModificacion);
$scope.op.fechaInicio=new Date($scope.op.fechaInicio);
$scope.op.mesReferencia=new Date($scope.op.mesReferencia);       
   });

  }]);




Could any of you help me with this problem?
thank you in advance for your time.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to