Skip to content

Instantly share code, notes, and snippets.

@SaurabhLpRocks
Created May 10, 2018 09:08
Show Gist options
  • Select an option

  • Save SaurabhLpRocks/84390bce35ca49515bbd1965e23847a6 to your computer and use it in GitHub Desktop.

Select an option

Save SaurabhLpRocks/84390bce35ca49515bbd1965e23847a6 to your computer and use it in GitHub Desktop.
import {AfterViewInit, ChangeDetectorRef} from '@angular/core';
@Component(…)
class AppComponent implements AfterViewInit {
constructor(private cdr: ChangeDetectorRef) {}
ngAfterViewInit() {
// We only want to detach the change detectors after change detection has been
// performed for the first time
this.cdr.detach();
}
update() {
// Run change detection only for this component when update() method is called.
this.cdr.detectChanges();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment