1

Let's say we have: <li *ngFor="let item of items" [@myTrigger]='state' (@myTrigger.start)="animStart($event)" (@myTrigger.done)="animDone($event)">{{ item }}</li>

And method animDone:

animDetails: string;

animDone(event:any) {
    console.log('Ended!');
    this.animDetails = 'I am done!';
}

In the view I have {{ animDetails }}

What's strange is while console.log('Ended!') fires appropriately, animDetails does not.

The first animation, nothing gets changed. The second animation (initiated by a click of a button), "I am done!" fires immediately, on start, as opposed to .done.

1 Answer 1

1

AFAIK animations run outside Angulars zone for performance reasons.

constructor(private cdRef:ChangeDetectorRef) {}

animDetails: string;

animDone(event:any) {
    console.log('Ended!');
    this.animDetails = 'I am done!';
    this.cdRef.detectChanges();
}

There was an issue about to run animation callbacks inside Angulars zone. I assume it was fixed already but your question seems to indicate otherwise, except when you're not using the latest Angular2 version.

Sign up to request clarification or add additional context in comments.

2 Comments

Ah! I'm using the Angular 2 quickstart for this particular example. Could that be why? By the way, I see your name everywhere in Angular 2. Great job!
Thanks. What do you mean with "quickstart"? angular.io/docs/ts/latest/quickstart.html? It seems to be using the latest version. The issue was fixed 10 days ago. It might not be included in the latest release. github.com/angular/angular/issues/11881

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.