I am using the greensock animation library to animate some components (as you would expect). I am experiencing an issue when I am updating a variable in the o
please refer to this Angular 2 documentation: Lifecycle Hooks
According to the documentation,
Angular's unidirectional data flow rule forbids updates to the view after it has been composed. Both of these hooks fire after the component's view has been composed.
Option1: use ngZone.run
to notify angular to render the view again.
// import ngZone from @angular/core first.
this.ngZone.run(() => {
console.log("anim complete");
this.rightVisible = false;
});
Option2: use ChangeDetector
to let angular to render the view again.
import {ChangeDetector} from '@angular/core';
this.rightVisible = false;
this.cd.detectChanges();
Refer this plunker that contains the upper code block.