Search code examples
angularngrx

Angular how to update UI for ChangeDetectionStrategy.OnPush


I'm have project write by Angular But in my component using ChangeDetectionStrategy.OnPush I update properti to new value from storage but UI not update So anyonce can help me solve this problem (can use Observeble for pipeAsync) Thanks

enter image description here


Solution

  • With OnPush, you need to tell Angular Component to detect change and update outside the event. With your case I think this.cdRef.markForCheck(); // Tell Angular to run detectChanges on this component Might work.