AngularJS.de - Animations with ng-repeat (jQuery) 1.2
Example for AngularJS with ng-repeat and ng-animate with jQuery.
by angularjs_de
HTML
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular-animate.min.js"></script>
<button ng-click="replaceItem()">Go!</button>
<ul>
<li ng-repeat="item in items" class="list-item">{{item}}</li>
</ul>
JavaScript
angular.module('myApp', ['ngAnimate']);
angular.module('myApp').controller('MainController', function($scope) {
$scope.items = [1,2,3,4,5,6,7,8,9];
$scope.replaceItem = function() {
$scope.items.shift();
$scope.items.push(Math.floor(Math.random()*1000000000));
};
});
angular.module('myApp').animation('.list-item', function() {
return {
beforeAddClass: function(element) {
jQuery(element).css({ 'line-height': 0 });
},
enter : function(element, done, memo) {
jQuery(element).animate({ 'line-height': '20px' },
function() { done(); });
}
};
});