I am trying to implement ngAnimate on a custom directive that is repeated using ng-repeat in my AngularJS application. The animations function correctly when I use ng-repeat on a simple HTML list-item. However, when I replace the list-item with a custom directive element, the animation fails to trigger.
Can anyone point out what I might be missing or doing wrong in this scenario?
For reference, here is a Plunker demo showcasing the issue: Plunker Demo
HTML
<h3>Simple ng-repeat</h3>
<ul>
<li class="animate-repeat" ng-repeat="val in testValues">{{ val }}</li>
</ul>
<h3>ng-repeat on custom directive</h3>
<ul >
<animation-test class="animate-repeat" ng-repeat="val in testValues" test-val="val"></animation-test>
</ul>
Javascript
var app = angular.module('application', ['ngAnimate']);
app.controller('mainController', [ '$scope', mainController]);
function mainController($scope){
// just for demo purposes
$scope.testValues = [];
$scope.addItem = function(){
var len = $scope.testValues.length;
$scope.testValues.unshift('Value #' + len);
};
$scope.removeItem = function(){
$scope.testValues.pop();
};
}
app.directive('animationTest', animationTest);
function animationTest(){
return {
template: ' <li> {{testVal}} </li> ',
scope: {
testVal: '<'
}
};
}
CSS (uses animate.css )
.animate-repeat.ng-enter {
animation: 0.5s slideInUp;
}
.animate-repeat.ng-leave,
.animate-repeat.ng-move {
animation: 0.5s slideOutDown;
}
@-webkit-keyframes slideInUp {
from {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
visibility: visible;
}
to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
@keyframes slideInUp {
from {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
visibility: visible;
}
to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
}
.slideInUp {
-webkit-animation-name: slideInUp;
animation-name: slideInUp;
}
@-webkit-keyframes slideOutDown {
from {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
to {
visibility: hidden;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
}
@keyframes slideOutDown {
from {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
to {
visibility: hidden;
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
}
}
.slideOutDown {
-webkit-animation-name: slideOutDown;
animation-name: slideOutDown;
}