angularangular2-changedetection

Triggering change detection manually in Angular


I'm writing an Angular component that has a property Mode(): string.

I would like to be able to set this property programmatically not in response to any event.

The problem is that in the absence of a browser event, a template binding {{Mode}} doesn't update.

Is there a way to trigger this change detection manually?


Solution

  • Try one of these:

    You can inject ApplicationRef, NgZone, or ChangeDetectorRef into your component.