How to manage Angular2 “expression has changed after it was checked” exception when a component property depends on current datetime
Run change detection explicitly after the change: import { ChangeDetectorRef } from ‘@angular/core’; constructor(private cdRef:ChangeDetectorRef) {} ngAfterViewChecked() { console.log( “! changement de la date du composant !” ); this.dateNow = new Date(); this.cdRef.detectChanges(); }