"Encountered a failure: [$injector:unpr]" while attempting to transfer information from a modal to a controller

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

Answer №1

After some investigation, I managed to come up with a solution on my own. It seems that the issue stemmed from a conflict between controllers - specifically, the modal being in ctrl1 while passing data to ctrl2. To resolve this, I simply created a service to encapsulate all of the modal's logic...

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Learn how to display two different videos in a single HTML5 video player

Seeking a solution to play two different videos in one video element, I have found that only the first source plays. Is jQuery the answer for this problem? HTML Code: <video autoplay loop id="bbgVid"> <source src="style/mpVideos/mpv1.mp4" type ...

Class Chat Practice Application

I'm a beginner in the world of programming and I could really use some assistance with troubleshooting my ChatApp. My goal is to have my server send the message "Robot: (client's username) connected" whenever someone logs on. I've been gra ...

What is the best way to create an HTML table according to the number of rows specified?

I need help creating a table in jQuery where the number of rows will be determined by an input box, and the number of columns is fixed. I have tried creating a fiddle but as I am new to jQuery, I am unsure of how to proceed. Here is the Fiddle link ...

Selecting a specific element and attaching a particular class to this element, but directing it towards a different element that shares the same index in a separate node list

I am working on a project where I have two sets of identical images - one is displayed in a gallery format and the other set is hidden until its corresponding gallery image is clicked, creating a lightbox effect. For example: <ul id="gallery"> ...

Opt for a submit <button> over an <input> button option

Is it possible to submit a form using <button> instead of <input>? I understand that a <button> cannot handle the form submission like a <input>, and I need to use the onclick method. I have attempted various solutions, but none se ...

Update a parent page section with new content once a child modal popup is closed

I've hit a roadblock with this problem and despite trying several solutions, I can't seem to get it right. Within my MVC6 view, there are multiple partials. One of the partials contains an anchor tag: @model ModelA <div> @Html.TextBoxF ...

Discover the position of a dynamically added element

Is there a way to identify the specific dynamically added checkbox that was clicked, whether by index or name? I came across a similar question with a solution in this JSFiddle: JSFiddle Instead of just displaying "clicked", I would like it to show someth ...

Modify the background color of a specific bar across multiple charts when hovering or clicking - utilizing chart.js

I have multiple chart.js canvas elements on a webpage. The goal is to be able to quickly identify and highlight the same bar value across all the charts. For example, when I hover over a bar called "Thu" on the first chart, I want to automatically search f ...

Discovering the center of an element and implementing a left float

I'm looking for a way to dynamically position the element #ucp_arrow in the middle of a div using float: left. Here is an illustration: https://i.stack.imgur.com/nzvgb.png Currently, I have hard-coded it like this: JAVASCRIPT: $("#a_account").cli ...

Combining objects in a JavaScript array based on a specific property

Here is an array I have: var array = [ { category: 'Input', field: 0, value: '17' }, { category: 'Input', field: 0, value: '5' }, { category: 'Input', field: 0, value: '8' }, ...

What could be causing my Angular/Express GET request to function properly while the POST request does not

My button setup includes Updates.getUpdates, which is working fine. However, Updates.postAnUpdate returns a 404 error. $scope.postUpdate = function () { console.log($scope.update); Updates.postAnUpdate($scope.update); Updates.getUpdates().the ...

How is it possible that my array becomes reversed without any intervention on my part?

As I work on developing a website, I encountered a puzzling issue with the calculations inside the router. Despite initializing the array tomato with the desired values, it seems that the values get reversed just before rendering the page. Here is the code ...

How to create flexible, non-url-changing layout states with angular-ui-router?

My Objective I am working with two different styles of display: "Normal": [ Header | Body | Footer ] - primarily used for most views "Discreet": [ Body ] only, centered on screen - ideal for states like login/register, errors etc. These display styles ...

Guide on how to press the enter key to submit a form instead of using a submit button

I am working on a form that has a button with the submit type, and I want it to be able to submit when the enter key is pressed. However, I'm unsure of how to achieve this functionality with the JavaScript function that I currently have in place for s ...

How can we convert multiple arrays into a single JSON object?

I have multiple arrays like the ones shown below: var a=[1,2,3,4,5,6,7,8,9]; var b=["a","b","c","d","e","f","g","h","i","j"]; However, I need to convert these arrays into an array object structured like this: ab=[ ["1","a"], ...

Ng-If Doesn't Work in the Current View

I'm having trouble updating the ng-if in my HTML code below: <div id="shyBoxII" ng-if="robot.robot" ng-class="background"> <div class="row"><i class="fa fa-user-plus"></i></div> <div class="row"><i clas ...

Tips for displaying a loading spinner during the rendering of a backbone view

I'm looking for some assistance in rendering a Backbone view that contains a large amount of information. Ideally, I would like to incorporate an animation (spinner) while the information is being rendered. Can anyone offer guidance or help with this ...

Here's a step-by-step guide on how to parse JSON information in JavaScript when it's formatted as key-value

I need to parse the JSON data in JavaScript. The data consists of key-value pairs. Data looks like this: {09/02/2014 15:36:25=[33.82, 33.42, 40.83], 08/11/2014 16:25:15=[36.6, 33.42, 40.45], 07/30/2014 08:43:57=[0.0, 0.0, 0.0], 08/12/2014 22:00:52=[77.99 ...

The ajax form submission is failing to function

On this page: <form method="post" id="userForm" name="userForm" class="form-validate" action="/istuff/index.php/user" > <input type="hidden" name="option" value="com_virtuemart"/> <input type="hidden" name="view" value="user"/> <input ...

Testing multiple regex patterns using jQuery

I am attempting to run multiple regex tests on an input field. Here is the script: $("#search-registration").keyup(function () { var input_data = $('#search-registration').val(); var regexTest = function() { this.withPrefix = /^ ...