Manually add ng animate to element

Is it possible to manually add NG animate to an element?

For example I want to add ng-enter and ng-leave when a ng-class is added or removed. But I also need ng-enter-active and ng-leave-active classes that gives me more control over the animation process.


Yes, you can. But you've to do some trick here like following.

Use https://daneden.github.io/animate.css/ for your application. It has nice animations by default. If you add this to your element, whenever the element inserted to the dom, there will be an animation.

But here in your scenario, add animate class whenever you add or remove class from your elements based on your condition. The sample code is below.

   <div ng-class="AddClass?'yourClass animated fadeIn':'animated fadeOut removedClass'"> 
</div>

It is not possible to remove a directive based on a class change in ng-class. However since you are applying a class in ng-class based on a condition, you could use that same expression in ng-if to include ng-enter or ng-leave.

链接地址: http://www.djcxy.com/p/27198.html

上一篇: JPQL:将Long转换为String来执行LIKE搜索

下一篇: 手动添加动画元素