Ionic modal remove method not working


#1

Dear community,
I need some help.
I use side menu in my app. When user click on some side menu item, I show a modal, for example, a login modal. When user close the modal, I want to remove it from the dom and destroy it to avoid memory leaking:

$scope.onCloseLoginModal = function () {
  $scope.loginModal.remove().then(function () {
    console.log("check if block modal still there");
    console.log($scope.loginModal);
  });

};

However, it doesn’t seem to be working. I still see the object and the output is the same as if I use the .hide() method. Why it behaves like this?

For using modal in other cases, I heard that the latest build of the 1.x version doesn’t listen to the “destroy” anymore if “cache” is enabled. How does Ionic destroy the modal then? Does Ionic do it automatically when the cache is invalid/expired?
ionic modal is a wonderful feature. Simple to use and very stable. However still hasn’t understand the behavior fully. Can you please help me?
thx.
-lola


#2

you can use $scope.$destroy(); of AngularJs