title: Why does detectChanges method cause "Attempt to use a destroyed view" Error?
body: <p><code>Error: ViewDestroyedError: Attempt to use a destroyed view: detectChanges at viewDestroyedError</code></p>
  
  <p>I get this error when going to another page while trying to trigger change detection by using <code>detectChanges</code> method in a component. I discovered that I don't get the error if I used <code>markForCheck</code> method. I'm aware of the difference from the two methods but I just don't get why <code>detectChanges</code> would cause this error during the destroy process. Any ideas?</p>
  
  <pre><code>import { Component, ChangeDetectorRef, OnInit } from '@angular/core';
  
  @Component({
      selector: 'my-app',
      templateUrl: './app.component.html',
      styleUrls: [ './app.component.css' ]
  })
  export class ChildComponent implements OnInit {
      data: any;
      constructor(
        private changeDetector: ChangeDetectorRef,
        private somethingService: SomethingService
      ) {
      }
  
      ngOnInit() {
          this.somethingService.getData().subscribe(data =&gt; {
              this.data = data;
              this.changeDetector.detectChanges();
          });
      }
  }
  </code></pre>