title: Angular: Location back history
body: <p>I have a form with a "back" button. When the user presses the back button, the script goes to the previous page:</p>
  
  <pre><code>import { Location } from '@angular/common';
  
  // In a place in La Mancha, whose name I do not want to remember...
  this.location.back();
  </code></pre>
  
  <p>But, what happens when the user directly enters the url in the address bar? In those cases the application goes back to the Browser's homepage. I would like something like this:</p>
  
  <pre><code>import { Location } from '@angular/common';
  
  // In a place in La Mancha, whose name I do not want to remember...
  if (this.location.history.length &gt; 0) {
      this.location.back();
  } else {
      this.router.navigate(['/home');
  }
  </code></pre>
  
  <p>Is that possible?</p>