I want to transfer an array object from a modal to a controller, but encountering the following error message:
"Uncaught Error: [$injector:unpr]"
I have defined a function in the resolve section that should return the array and injected this function into the controller. However, it seems like it's not working as expected. What could be the mistake I am making?
Here is the code snippet for the modal:
$scope.cercaClienteNomeCognome = function() {
if ($scope.nome == undefined){
var name = "";
} else name = angular.uppercase($scope.nome);
if ($scope.cognome == undefined){
var surname = "";
} else surname = angular.uppercase($scope.cognome);
var url = "servizi/getClienteNomeCognome?nomeCliente="+name+"&cognomeCliente="+surname;
$http.get(url)
.success(function(data, status, headers, config) {
if (data.length > 0) {
var modalInstance = $modal.open({
templateUrl: 'partials/modals/estensioneRicerca.html',
controller: 'estensioneRicercaController',
size : 'lg',
backdrop: 'static',
//keyboard: false,
resolve: {
returnArrayClienti: function () {
return data;
}
}
});
}
})
.error(function(data, status, headers, config) {
toaster.pop({
type : "Error",
title : "Ouh nou!",
body : "[RECUPERO CLIENTI] Errore durante il ritrovamento dei clienti"
});
});
};
And here we have the part relating to the controller:
angular.module("itasAcquire.controllers")
.controller('estensioneRicercaController', ['$scope', '$rootScope', 'ConfigPropertiesService', 'toaster', '$log', '$http', 'returnArrayClienti',
function ($scope, $rootScope, ConfigPropertiesService, toaster, $log, $http, returnArrayClienti) {
$scope.mostraToasterTemporaneo = function() {
var clienti = returnArrayClienti;
if (clienti == undefined) {
toaster.pop({
type : "Success",
title : "WAIT!",
body : "Attenzione! Non e' stato selezionato alcun tipo documento!"
});
} else {
toaster.pop({
type : "Success",
title : "Congrats!",
body : "Il cliente è stato selezionato! (" + clienti.CODICE_FISCALE + ")"
});
}
};
}]);
EDIT: Here is a screenshot of the error shown:
https://i.sstatic.net/9kxnh.jpg