We had $scope.$apply()
in angularjs that perform proper scope life cycle of angularjs.
Is there any equivalent to this in Angular 6?
You are looking for ChangeDetectorRef
Inject within your constructor
constructor(private ref: ChangeDetectorRef) {
}
and call
this.ref.detectChanges();
You can inject ChangeDetectorRef and use it for manually running change detection. It has methods that run change detection or stop it for that component. You can explore methods of ChangeDetectorRef
looking above link.
import { ChangeDetectorRef } from '@angular/core';
@Component({
...
})
export class MyComponent {
constructor(private changeDetector: ChangeDetectorRef ) {
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With