Difficulty closing Modal Popup when multiple Modals are displayed simultaneously

I am facing a challenge with transitioning between modal screens

When the button on the screen is clicked, Modal1 opens:

$modal.open({
    templateUrl: 'abc.html',
    controller: 'abcCtrl',
    size: 'lg',
    scope: $scope,
});

In Modal1, there is a Next button that, upon click, should close Modal1 and open Modal2:

$scope.validate = function(isValid) {
    if (!isValid) {
        $scope.errors = 'Please fill-up required fields';
    } else {
        $scope.errors = '';
        $modal.open({
            templateUrl: 'Payment.html',
            controller: 'PaymentCtrl',
            size: 'lg',
            scope: $scope,
        });
    }
};

In Modal2, there is another Next button that, when clicked, should close Modal2 and open Modal3:

$scope.placeOrder = function() {
        $scope.cart.abc().then(function(result) {
                $modal.open({
                    templateUrl: 'orderSummary.html',
                    controller: 'SummaryCtrl',
                    size: 'lg',
                    scope: $scope,
                    resolve: {
                        items: function() {
                            return result.data;
                        }
                    }
                });
            },
            function(err) {
                //error msg
            });
};

The issue arises when I add $modalInstance.close to Modal1. When opening Modal2 after closing Modal1, none of the buttons seem to work. Modal3 does not get opened as expected. The exact cause behind this behavior is unknown to me.

Any assistance or insight would be greatly appreciated. Thank you in advance.

Answer №1

Do you seek the wisdom of a sorcerer?

Check out this link

Answer №2

Start by initializing the Main Controller and opening Modal1. When Modal1 closes, execute the following:

 var modalInstance = $modal.open({
                templateUrl: 'xyz',
                controller: 'xyzCtrl',
                size: 'md',
                scope: $scope,
             });

            modalInstance.result.then(function(result) {
                  $scope.ghi();
              }, function(err) {
                //
            });

  $scope.ghi = function(){
     //open another modal 
    }

Invoke another function that will open yet another modal, continuing this pattern as needed.

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

Transform each element in the array individually

I am seeking a method to transform every element within an array into the format shown below for new users. var userids=['792','796','788','676' etc...] The desired outcome is as follows: var newusers=["792"]["796 ...

Using AJAX to Query a PHP Database

Currently, I am implementing an AJAX call from the YouTube player JavaScript to a PHP page that contains various functions, mainly involving database inserts. In my PHP code, I use a case statement to determine which function is being called based on the d ...

What could be causing my state not to change in Nextjs even though I followed the quick start guide for Easy Peasy?

I recently encountered an issue while trying to implement easy peasy for global state management in my nextjs app. The problem I faced was that the state would only update when I changed pages, which seemed odd. To better understand what was going on, I de ...

Achieving proper HTML element order?

Here is the HTML page I am working with: Click here to view the code on jsfiddle <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Extended UI</title> <style type="text/css"> .header{ padding-rig ...

I am experiencing a 404 error when attempting to import a local JS file in Angular

After creating a new project with "ng new xxx", all you need to do is add one line of code in index.html: <!doctype html> <html lang="en> <head> <meta charset="utf-8> <title>Bbb</title> <base href="/&g ...

Master the art of horizontal scrolling in React-Chartsjs-2

I recently created a bar chart using react.js and I need to find a way to enable horizontal scrolling on the x-axis as the number of values increases. The chart below displays daily search values inputted by users. With over 100 days worth of data already, ...

Using JQuery, eliminate the transition effect from a child CSS class

I am facing an issue with transitioning an ID that has a child class. My goal is to transition the ID only, without affecting the class within it. Despite going through CSS and jQuery documentation, I have been unable to achieve this. The transitions are c ...

Utilizing a function as a value in React state (setState) compared to defining state with constructor in a class and utilizing a state object

Can someone help me understand the concept of state in React better? I'm confused about the differences between these two implementations: This: class Todo extends ... { constructor (){ super() this.state = { ... } } } And This: class Todo extend ...

Organizing an array based on designated keywords or strings

Currently, I am in the process of organizing my logframe and need to arrange my array as follows: Impact Outcomes Output Activities Here is the initial configuration of my array: { id: 15, parentId: 18, type: OUTPUT, sequence: 1 }, { id: 16, parentId: ...

What is the best way to create a repetitive pattern using a for loop in Javascript?

I want to create a repeating pattern to color the background, but once i exceeds colors.length, the background color stops changing because, for example, colors[3] does not exist. I need colors[i] to start back at 0 until the first loop is complete. cons ...

Fetching JSON data from an external API using JavaScript

What is the most efficient way to load a JSON feed from an external source using JavaScript? I am familiar with PHP's file_get_contents and cURL methods, but is there a similar function or approach in JavaScript? ...

Update the image source every 1 second with Jquery and Javascript

I've been experimenting with creating a script that dynamically changes the source of an image every two seconds based on a list. Essentially, my current approach involves using a for loop to iterate over the provided list: $(document).ready(functio ...

Express Concurrency: Managing Multiple Tasks Simultaneously

Looking to create an API using Express that is capable of processing requests either through multithreading or multiprocessing. For example, the following API has a 5-second sleep before responding. If I make 3 quick calls to it, the first response will ta ...

Employing ngModel within an (click) event in Angular 4

I have this html code snippet: <div class="workflow-row"> <input type="checkbox" id="new-workflow" [(ngModel)]="new_checkbox"> <label>New Workflow</label> <input type="text" *ngIf="new_checkbox" placeholder="Enter ...

Merging Data with mongoDB

Just starting out with MongoDB, I have developed an app that functions similar to Twitter with followers and following. Here is the schema I am working with: UserSchema : username:'Alex', pass:'salted', likes:'200&ap ...

The map markers are nowhere to be found on the map when using Internet Explorer

Take a look at this code I wrote... var styles = [ { "featureType": "landscape", "stylers": [ {"weight": 0.1}, {"color": "#E7EDEF"} ] }, ... { "featureType": "poi.park", "elementType": "labels", "stylers": [ ...

AngularJS: Loading $http Responses in Batches of 5 or Fewer Items

Currently, I am developing a product catalog application using the Ionic Framework. The backend is powered by PHP to fetch products from the database, and AJAX is utilized to display them on the frontend. Everything seems to be functioning well until I att ...

Combining all CSS files into one and consolidating all JavaScript files into a single unified file

Whenever I need to add a new CSS or JS file, I always place it in the header section like this Add CSS files <link rel="stylesheet" href="<?php echo URL; ?>public/css/header.css" /> <link rel="stylesheet" href="<?php echo URL; ?> ...

Versatile accordion with separate functionalities for items and panels

When I have different functions for clicking on item and title, clicking on the item works fine but clicking on the panel triggers both functions. Is there a way to resolve this so that I can click on the item using Function_1 and click on the panel using ...

Using AngularJS API within a standalone function: Tips and tricks

I'm diving into the world of AngularJS and I want to make an HTTP GET request to a distant server without messing up my current view code. After some research, I discovered a way to execute a function right after the HTML is loaded by using a standalo ...