I use angularjs to add animation to a table when array in scope changes. here is the HTML code:
<div ng-app="myapp" ng-controller="myCtrl">
<table>
<tr ng-repeat="x in items track by $index" class="fade2">
<td >
{{ x }}
</td>
</tr>
</table>
<button ng-click="add()">add</button>
<button ng-click="reset()">reset</button>
</div>
and the javascript code:
var app = angular.module('myapp', ['ngAnimate']);
app.controller('myCtrl', function($scope) {
$scope.items = ['hello'];
$scope.add = function() {
$scope.items.push('hello')
}
$scope.reset = function() {
$scope.items = ['hello','hello','hello','hello'];
}
});
after add some CSS, it works fine if I click the button 'add' and 'reset', however, when I click the reset twice, there is no animation. Actually the array is updated but the elements in the $scope.items array doesn't change. How can I add a animation for this situation?