I have written a function to open ionic popup on click of device back,problem is as soon as I click device back multiple times, the popup gets created that many times and remains in DOM. How can I close previous popup and create a new one again?
App Exit Popup:
$rootScope.exitApp = function () {
exitpopup = $ionicPopup.show({
templateUrl: 'templates/exitApp1.html'
});
exitpopup.then(function (res) {
console.log(res);
});
return false;
};
RegisterBack function :
$ionicPlatform.registerBackButtonAction(function (e) {
// lots of code
if ($ionicHistory.backView())
$rootScope.exitApp ();
});
Am I missing something ?