You need to be using addClass and removeClass not add/remove. Also you need three parameters (element, className, done) you are missing the second.
AngularJS ng-class javascript animations doesn't trigger
-
30-06-2022 - |
Question
I'm trying to attach js-defined animations to the ng-class directive via the usual syntax using add and remove but the animations won't run. Logging reveals that the add and remove functions don't get called.
app.animation( ".bob", function () {
return {
add : function ( element, done ) {
// Do add animation here and call done when done.
},
remove : function ( element, done ) {
// Do remove animation here and call done when done.
}
}
} );
This usually works fine with other directives like ngIf with it's enter and leave animations, but with ngClass it only seems to work with css-animations as proved by the example in the documentation
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow