btford / angular-modal

Simple AngularJS service for creating modals

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not compatible with angular.js v1.3.0-rc.0 sonic-boltification

ryanhart2 opened this issue · comments

$animate.leave no longer accepts a callback as a second parameter, but instead returns a promise.

In the code shown below, the anonymous function passed to $animate.leave is never executed. As a result of the element variable not being set to null, the modal is not displayed on subsequent activate calls.

function deactivate () {
  var deferred = $q.defer();
  if (element) {
    $animate.leave(element, function () {
      scope.$destroy();
      element = null;
      deferred.resolve();
    });
  } else {
    deferred.resolve();
  }
  return deferred.promise;
}

This is the commit that made the breaking change.

@ryanhart2 thanks for finding all that. I'm not sure the best way to fix this based on versions other than to just switch it over to use the promise. However, this would then break people using older versions of angular and it would seem to be clunky to add version detection to the directive. I wonder if the solution is to just stop supporting older 1.2 once 1.3 becomes final or if there is something more elegant?

function deactivate () {
  var deferred = $q.defer();
  if (element) {
    $animate.leave(element).then(function () {
      scope.$destroy();
      element = null;
      deferred.resolve();
    });
  } else {
    deferred.resolve();
  }
  return deferred.promise;
}

I created a fork and and a pull request which use the new signature of $animate.leave(). #30

@chrisguttandin awesome, looks good to me.

Should be fixed in v0.5