Issue with injection occurring due to the utilization of ui-bootstrap

Encountered issue: $confirmModalProvider <- $confirmModal <- confirmModalCtrl

Why is this error popping up? I am attempting to utilize AngularJS UI Bootstrap for launching a modal and fetching the result. This error arises when I call $scope.deleteQuestion(). Any insight into what might be going wrong in my approach?

var crtPromoCtrl = angular.module('crtPromoCtrl', ['crtPromoSrv']);

crtPromoCtrl.controller('surveyCtrl', ['$scope', '$modal', 'surveySrv', function($scope, $modal, surveySrv)
{
        $scope.questions = surveySrv.getQuestions();

    $scope.editQuestion = function(index)
    {
        surveySrv.setEditQuestion(index);
    };

    $scope.deleteQuestion = function(index)
    {
        var confirmModal = $modal.open({
            templateUrl: 'confirm-delete.html',
            controller: 'confirmModalCtrl',
            size: 'sm'
        });

        confirmModal.result.then(function(msg)
        {
            console.log(msg);
        });

        return false;
    };
}]);

crtPromoCtrl.controller('confirmModalCtrl', ['$scope', '$confirmModal', function($scope, $confirmModal)
{
    $scope.yes = function()
    {
        $confirmModal.close('yes');
    };

    $scope.no = function()
    {
        $confirmModal.dismiss('no');
    };
}]);

UPDATE: https://angular-ui.github.io/bootstrap/#/modal

Answer №1

It is recommended that your second controller utilizes $modalInstance instead of $confirmModal

Keep in mind that $modalInstance represents a modal window instance dependency.

Code

crtPromoCtrl.controller('confirmModalCtrl', ['$scope', '$modalInstance', function($scope, $modalInstance) {
    $scope.yes = function() {
        $modalInstance.close('yes');
    };

    $scope.no = function() {
        $modalInstance.dismiss('no');
    };
}]);

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

What is the best way to retrieve the current URL with a hashtag symbol using JavaScript?

I am attempting to display the current URL after the question mark with a hash symbol using PHP, but unfortunately, it is not achievable. Therefore, I need to utilize JavaScript for this task, even though I have limited knowledge of it. This is the specifi ...

The switchMap function is sending back a single item

I'm having an issue with switching the observable using the switchMap operator: return this.db.list(`UserPlaces/${this.authData.auth.auth.currentUser.uid}`, { query: { orderByChild: 'deleted', equalTo: false } }) .ma ...

Guide to loading a Canvas texture in a Wavefront OBJ using three.js

Hello there! I am currently working on a project where I am using three.js to display an obj file exported from Blender and map a texture from a canvas onto it. I managed to successfully display the image in obj format, but when I tried to apply the canvas ...

Sharing data between nested ng-repeat in Angular can be achieved by utilizing scope inheritance

I am currently experiencing an issue with a nested ng-repeat structure. Below is a snippet of my sample HTML code. I need to determine the number of rows with the id "thirdNg" (number_of_thirdNg_row) after applying a filter to the parent3 ng-repeat with ...

Displaying errors while using Dropzone to upload a photo

Hi, I'm facing an issue with uploading images using jQuery. Whenever I try to upload an image, I encounter errors. How can I resolve this problem? The reason I can't use the dropzone form is because it belongs to a different form. Here are the e ...

Automatic Navigation Disappear in AngularJS

Is there a way to create a fixed navigation menu that automatically hides and shows up like the auto-hide taskbar feature in Windows? I want it to disappear when not in use, but reappear as soon as you move your mouse close to the top of the screen. Any s ...

Accessing Data from the Wikipedia API

After receiving a JSON response with the following structure: { "batchcomplete": "", "query": { "pages": { "97646": { "pageid": 97646, "ns": 0, "title": "Die Hard", "extract": "Die Hard is a 1988 ...

Angular directive dilemma

Angular is causing some issues for me as I am a beginner in using it. Below is the JSON data that I am dealing with: [ { "name":"43", "values":{ "audio":"Audio Only", "low":"Low Bandwidth", "medium":"Medium Bandw ...

Excessive calls to the component update in React with Javascript are leading to application crashes

componentDidUpdate() { // Retrieving trades from the database and syncing with MobX store axios.get(`http://localhost:8091/trade`) .then(res => { this.props.store.arr = res.data; }) } After implementing this code, my ...

The current error message states that the function is undefined, indicating that the Bookshelf.js model function is not being acknowledged

I have implemented a user registration API endpoint using NodeJS, ExpressJS, and Bookshelf.js. However, I encountered an error while POSTing to the register URL related to one of the functions in the User model. Here is the code snippet from routes/index. ...

Searching for dates within a range on DataTables using CodeIgniter

Can someone assist me in displaying data within a selected date range? Here is the code snippet I have so far: Below is the code for displaying the data tables: View <div class="box-body"> <div class="table-responsive"> ...

Guide on utilizing JSON data sent through Express res.render in a public JavaScript file

Thank you in advance for your assistance. I have a question that has been on my mind and it seems quite straightforward. When making an app.get request, I am fetching data from an external API using Express, and then sending both the JSON data and a Jade ...

Organize the words within HTML elements without considering the tags

My webpage contains buttons that appear as follows: <button>Apple</button> <button>Dog</button> <button>Text</button> <button>Boy</button> <button class='whatNot'>Text</button> <butt ...

How to Fetch a Singular Value from a Service in Angular 4 Using a Defined Pattern

I am currently working on developing a service in Angular 4 (supported by a C# RESTful API) that will facilitate the storage and retrieval of web-application wide settings. Essentially, it's like a system for key-value pair lookups for all common appl ...

Encountering Internal Server Error when C# WebMethod communicates with JavaScript AJAX call

I've encountered an issue where my AJAX call to a C# WebMethod is not returning the expected result. Instead, it keeps showing an "Internal Server Error" message. A button triggers a JavaScript function: <button id="btn" onclick="Create();">fo ...

What are some effective ways to utilize the outcome of a FB FQL multiquery?

I'm having some confusion with Facebook's fql.multiquery feature. My goal is to fetch all the comments on a specific post and then retrieve the user information for each commenter. While I can easily get the comments, I am facing difficulty in o ...

Disabling dates in Kendo Date Time Picker (Angular): An easy guide

<input id="startDate" kendo-date-time-picker k-ng-model="vm.startDate" k-on-change="vm.updateStartDate()" required /> Can someone please explain how to incorporate disabled dates into this date picker without utilizi ...

The deletion function necessitates a switch from a server component to a client component

I built an app using Next.js v13.4. Within the app, there is a server component where I fetch all users from the database and display them in individual cards. My goal is to add a delete button to each card, but whenever I try to attach an event listener t ...

Please optimize this method to decrease its Cognitive Complexity from 21 to the maximum allowed limit of 15. What are some strategies for refactoring and simplifying the

How can I simplify this code to reduce its complexity? Sonarqube is flagging the error---> Refactor this method to reduce its Cognitive Complexity from 21 to the allowed 15. this.deviceDetails = this.data && {...this.data.deviceInfo} || {}; if (th ...

What is the best method for extracting span text using selenium?

<p id="line1" class=""><span class="bot">Do you have a short-term memory?</span><span id="snipTextIcon" class="yellow" style="opacity: 1;"></span></p> I want to extract this text: Do you have a short-term memory? This ...