我正在尝试通过组合对addClass / removeClass的调用来制作动画序列.
在动画结束后,调用“removeClass”来删除动画并启动一个新动画.但由于某种原因,没有任何反应.我想弄清楚它为什么不起作用?为什么不删除课程?
$animate.addClass(element,'fadeInDown').then(function() { $animate.removeClass(element,'fadeInDown'); // why is it not working? $animate.addClass(element,'fadeOutDown'); });
完整版可以在这里找到
解决方法
你可以看看我在你的plunker中制作的这个黑客:
http://plnkr.co/edit/iMMdPUrIz132PsCtB2Uq?p=preview
var myApp = angular.module('myApp',['ngAnimate']); myApp.controller('Controller',function($scope) {}); myApp.directive('animated',['$animate','$window',function($animate,$window) { return function(scope,element,attrs) { scope.animate = function() { $animate.addClass(element,'fadeInDown').then(function() { $animate.removeClass(element,'fadeInDown'); // why is it not working? setTimeout(function() { scope.$apply(function() { $animate.addClass(element,'fadeOutDown'); }); },0); }); }; }; }]);