Closing multiple ionic modal using escape button


#1

I have ionic modal that open another modal again that modal open another modal, but when i pressed escape button all modal are closing at the the same time i need to close them one by one.
This is my code for closing modal.
> hotkeys.bindTo($scope).add({
> combo: ‘esc’,
> description: ‘window should close’,
> callback: function () {
> $scope.closeNewItem();
> $scope.closeItemDetails();
> $scope.closeCalc();
> $scope.CloseCategoryItemsModal();
> $scope.closeCategoryModel();
> $scope.closeUnitModel();
> $scope.closeTaxModel();
> $scope.closeDiscountModel();
> $scope.closeIMEIModal();
> $scope.closeStockUpdateIMEIModal();
> }
> });


#2

That looks more like Ionic v1 code, right? I changed the post category.

Your code says "If I hit ESC, please call all these close-functions. You should change it, so that it checks which one is actually open and only run the “newest” close function. (Imagine the modals are called 1, 2, 3, 4, … - if “3” is open but “4” isn’t you can then run the “close” function for “3” as it is the “top” modal) (If there is not only one order of the modals to be opened, you will have to track the “open order” somehow yourself.)