ngif not updating on variable change code example

Example: ngIf not detecting var change

//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 ChangeDetectorRef from @angular/core first.
import {ChangeDetectorRef} from '@angular/core';
constructor(private cd: ChangeDetectorRef) {}
this.rightVisible = false;
this.cd.detectChanges();