How to have different modal exit animations?


#1

Hi.
Im just wondering if its possible to change a modals animation once it has loaded ie have a different exit animation depending on the option a user has selected. eg either slide right or slide left.

This is a simple example that I’ve tried. Note the function selectItem, which tries to change the exit animation. But it doesn’t work and the original animation is always used…

function showPicker(items) {

    var deferred = $q.defer();

    $ionicModal.fromTemplateUrl('partials/picker.html', { 
        animation: 'slide-in-right' 
    }).then(function (modalCtrl) {
    
        var scope = modalCtrl.scope;

        scope.model = {};
        scope.model.items = items;
       
        scope.selectItem = function (item) {
            
            modalCtrl.animation = 'no-animation';
            
            deferred.resolve(item);
            modalCtrl.remove();
        };

        scope.closeModal = function () {
            deferred.resolve();
            modalCtrl.remove();
        };

        modalCtrl.show();
    });

    return deferred.promise;
}