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
Asked
Active
Viewed 1,297 times
-2
-
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 Answers
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
}

huzaifamandviwala
- 415
- 2
- 5
-
1This should be a comment, but is fair enough as an answer, given the question. – Jeremy Thille Aug 08 '19 at 13:42
-
I have used OnDestroy In my components, But how to use this.ref.detectChanges() – Sumanth Maguluri Aug 08 '19 at 14:05
-