Enter animation not playing in Angular

谁都会走 提交于 2019-12-11 09:27:15

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!