Botteu
Botteu

Reputation: 33

AngularJS ng-class javascript animations doesn't trigger

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

Upvotes: 3

Views: 781

Answers (1)

Daniel Tabuenca
Daniel Tabuenca

Reputation: 13681

You need to be using addClass and removeClass not add/remove. Also you need three parameters (element, className, done) you are missing the second.

Upvotes: 2

Related Questions