问题
I'm wondering how could I animate an element when the angular app is starting.
Indeed, I see (I'm maybe doing something wrong) that the animation module is not triggering the "enter" event the first time, but after everything goes fine. How could I animate it without rewriting all the code I have in my animation module somewhere else ?
You can see on my fiddle that the li is green at first glance, when I need it to be blue as defined in my enter animation.
I don't know if it only occurs in my configuration which is the following :
<li ng-if="$index === value" ng-repeat="proj in projects" class="test-anim">test</li>
, animating the test-anim class.
Thanks for your answers
回答1:
This is by design in 1.2.3. See this issue:
https://github.com/angular/angular.js/issues/5130
You could use a timeout like this to try to wait until the page is rendered before adding data to your ng-repeats/ng-if:
$timeout(function(){
$scope.value = 0;
$scope.projects = [{}, {}, {}];
}, 0);
来源:https://stackoverflow.com/questions/20586827/enter-animation-not-playing-in-angular