I have created a table in which user can increase and decrease the value. See the Fiddle
//sample code as its not allowing me to push the link to JSFiddle with out pasting code
<tr ng-repeat="d in dataSource" ng-animate="'animate'">
// css - as from angular page
.animate-enter {
-webkit-transition: 1s linear all; /* Chrome */
transition: 1s linear all;
background-color:Yellow;
}
.animate-enter.animate-enter-active {
background-color:Red;
}
I want to do animation when the model updates i.e the table column changes in background color From Red to white in case user changes the value.
So when you click up arrow or down arrow in any perticular column, the background color of that table column changes from Red to white.
I am not able to get my head around it. Any pointers on how to achieve this ?
This can be solved with a simple directive and CSS3 animations.
HTML
Directive
CSS
Fiddle
in Angular 1.5 u can use ngAnimateSwap built in directive.
From the docs:
There are couple of issues in your code:
NEVER do DOM manipulations in the code of controller:
$(elem).animate(..
is something you should avoid. Only in directives you can manipulate with DOM element.In 1.2+ versions of AngularJS you need to reference
ngAnimate
module.It is better to do CSS3 animations with fallback to js-based animations.
I propose to write a directive that will track changes and add a class that will trigger the animation and then remove it:
Working example: http://plnkr.co/edit/zs495osfSnWSvWBIn3rh?p=preview