1

I want to back in history if exist in Angular 7.*?
I used the following:

  import { Location } from '@angular/common';

    constructor(private location: Location) {

  }

    get isBackHistoryExist(): boolean {
    return window.history.length > 1;
  }
  back(): void {
    this.location.back();
  }

But window.history.length > 1 is always true !

Mohammad Dayyan
  • 21,578
  • 41
  • 164
  • 232
  • 1
    Check this https://stackoverflow.com/questions/3588315/how-to-check-if-the-user-can-go-back-in-browser-history-or-not – taras-d Mar 20 '19 at 18:40

0 Answers0