Skip to content

Instantly share code, notes, and snippets.

@AregSargsyan
Created May 31, 2020 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AregSargsyan/5b45eb15d70d983906cde164c289b53c to your computer and use it in GitHub Desktop.
Save AregSargsyan/5b45eb15d70d983906cde164c289b53c to your computer and use it in GitHub Desktop.
datectChanges
import { Component, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core';
@Component({
template: `...`,
changeDetection: ChangeDetectionStrategy.OnPush
})
export class CounterComponent {
count = 0;
constructor(private cd: ChangeDetectorRef) {
setTimeout(() => {
this.count++
this.cd.detectChanges()
}, 0);
this.http.get('https://count.com').subscribe(res => {
this.count = res;
this.cd.detectChanges()
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment