jcroll
jcroll

Reputation: 7165

Is there any way to find out what is triggering change detection in Angular 2?

I recently released a new component and it seems to be triggering change detection multiple times a second:

  // some debugging code
  ngDoCheck() {
    console.log('DO_CHECK', new Date().toLocaleTimeString());
  }

Results:

enter image description here

I've yet to figure out what is triggering this.

Am I reading this output correctly? Change detection is being triggered multiple times a second?

Is there any good method for figuring out what is triggering change detection in an Angular 2 application?

Upvotes: 12

Views: 3896

Answers (1)

slim
slim

Reputation: 503

The Angular DevTools for Chrome provide a profiler that will list all change detection events and will show the source for each event.

Upvotes: 1

Related Questions