-2

I am working with the angular application (Angular7), For some reason, I am getting console errors, I am unable to find the scenario for these errors, can anyone guide me why these errors are coming?Please Click here for Image

R. Richards
  • 24,603
  • 10
  • 64
  • 64
  • Please update your question with a reproducible example of the problem on stackbliz. This might help: https://brianflove.com/2016/12/11/anguar-2-unsubscribe-observables/ – Reactgular Aug 08 '19 at 13:49

1 Answers1

1

I'll tell you the point that could help you to solve the issue.

The issue clearly comes from detectChanges() because the changes were done and the method called during the destroy phase of the component.

So you need to make your component to implements OnDestroy, then you need to cancel the changes that make this.ref.detectChanges() to be called.

Reference: Attempt to use a destroyed view: detectChanges

Example:

export class SampleComponent implements OnDestroy {
  // ... your code

  constructor( private ref:ChangeDetectorRef) {}

  ngOnDestroy() {
    this.ref.detach(); // do this
}