How to trigger change detection in Angular?

Forums AngularHow to trigger change detection in Angular?
Staff asked 3 years ago

I perform add, update and delete operations on the grid but I can’t able to refresh the grid without refreshing the page. How Can I dothis?

Answers (1)

Add Answer
Staff answered 3 years ago

Using detect changes() in a component will immediately run change detection in that component and its children. This method is helpful when we refresh the gird after performing any operation on it. It will automatically refresh the grid without refreshing the page.

First import ChangeDetectorRef to component where we want to use it.

import { ChangeDetectorRef } from ‘@angular/core’;

Now inject it.

constuctor(private changeDetactor : ChangeDetectorRef )

{

}

After that use it in method where you perform manipulation operations. Use detectChanges method to do this.

this.changeDetactor.detectChanges()

 

 

Subscribe

Select Categories