【发布时间】:2014-12-28 23:07:58
【问题描述】:
所以我有一个简单的 ng-repeat,其中包含在 javascript 中定义的输入动画。
沙盒:http://codepen.io/anri82/pen/KwgGeY
代码:
<div ng-app="myApp" ng-controller="MyController">
{{state}}
<ul>
<li class="repeat-animate" ng-repeat="item in list">{{item}}</li>
</ul>
<button ng-click="add()">add</button>
</div>
angular.module('myApp', ['ngAnimate'])
.controller("MyController", function($scope) {
$scope.state ="idle";
$scope.id=3;
$scope.list = [1,2];
$scope.add = function () {
$scope.state="pushing";
$scope.list.push($scope.id++);
$scope.state="done pushing";
};
}).animation('.repeat-animate', function () {
return {
enter: function (element, done) {
element.hide().show(2000, done);
}
};
});
只有在动画完成后,我如何将$scope.state 切换到done pushing?答案应该是有角度的,不要建议setTimeout。
【问题讨论】:
标签: javascript angularjs ng-animate