What is the need of $scope.closeModal?


Here is my code…If I remove close modal function,there is no effect. If I click any where outside the modal, the modal closes. But I need this close modal function as I need to set a flag in it for further use. How can I proceed further?

$scope.$on(’$ionicView.afterEnter’, function() {
$ionicModal.fromTemplateUrl(“settings/settingsModal.html”, {
scope: $scope,

   animation: 'slide-in-up'
 }).then(function(modal) {
   $scope.modal = modal;

$scope.openModal = function(){
$scope.closeModal = function(){



Please help me in this issue…Thanks