Created
May 10, 2018 09:08
-
-
Save SaurabhLpRocks/84390bce35ca49515bbd1965e23847a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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