title: Warn user of unsaved changes before leaving page
body: <p>I would like to warn users of unsaved changes before they leave a particular page of my angular 2 app. Normally I would use <code>window.onbeforeunload</code>, but that doesn't work for single page applications.</p>
  
  <p>I've found that in angular 1, you can hook into the <code>$locationChangeStart</code> event to throw up a <code>confirm</code> box for the user, but I haven't seen anything that shows how to get this working for angular 2, or if that event is even still present. I've also seen <a href="https://github.com/marcorinck/angular-onbeforeunload">plugins</a> for ag1 that provide functionality for <code>onbeforeunload</code>, but again, I haven't seen any way to use it for ag2.</p>
  
  <p>I'm hoping someone else has found a solution to this problem; either method will work fine for my purposes.</p>