Richard Mc
Richard Mc

Reputation: 162

Ng-dialog - close child modal

I have a parent dialog that will open another child dialog. I have the function to open a ngDialog

function addNewImageModal(rel) {

    $scope.rel = rel;

    ngDialog.open({
        template: 'partials/image_modal.jade',
        className: 'ngdialog-theme-default',
        controller: 'ModalInstanceCtrl',
        scope: $scope,
        closeByDocument: false,
        showClose: false,
        closeByEscape: false
    });
}

and then in the template I have a ng-click which calls a functions which handles uploading an image. I am trying to get it to just close the child dialog but with no success. Currently I have it as

ngDialog.close("partials/image_modal.jade");

How do I close the child dialog but keep the parent one open

Upvotes: 0

Views: 1856

Answers (1)

Lyudmil Petrov
Lyudmil Petrov

Reputation: 11

It is very simple. Take all open windows objects in a variable using pre-defined method:

getOpenDialogs()

So this method will return an array(0-n) of all open dialog window objects. So close the dialogue which you want to close by index like:

ngDialog.Close(myDialogList[index])

For-Example

var windowIDs = ngDialog.getOpenDialogs();
ngDialog.close(windowIDs[1]);

Upvotes: 1

Related Questions