$ionicModal is not calling the openModal function


#1

$ionicModal.fromTemplateUrl(‘modal.html’, {
scope: $scope,
animation: ‘slide-in-up’
}).then(function(modal) {
$scope.modal = modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
//Cleanup the modal when we’re done with it!
$scope.$on(’$destroy’, function() {
$scope.modal.remove();
});
});

I am trying to use this above function to show modal. Modal works fine but the openModal and closeModal functions is in $scope but functions is not called when opening and closing the modal ?


#2

With the exception of the extra }); at the end of the code (I’m assuming that’s the closing of your controller), I don’t see anything particularly wrong.

How can “Modal works fine” if you are also saying “openModal” and “closeModal” don’t work?

Here is a working Modal example : http://codepen.io/ionic/pen/gblny

Perhaps you can fork that and put in your actual code so we can see what’s going on?