title: Angular2 - Prevent ngOnDestroy from happening
body: <p>I have a page that has a form that checks if the user has unsaved changes before navigating away from it.</p>
  
  <p>The problem is that even with a preventDefault() and return false, the user is still able to click away from the component.</p>
  
  <p>Is there a way to prevent the ngOnDestroy or click event from happening?</p>
  
  <p><strong>Note</strong>: User is not going to a different route, just another tab from the same component.</p>
  
  <pre><code>ngOnDestroy() {
      if (this.myForm.dirty) {
          let save = confirm('You are about to leave the page with unsaved changes. Do you want to continue?');
          if (!save) {
              window.event.preventDefault();
              return false;
          }
      }
  }
  </code></pre>