-2

I have a page that I can access it from to two diff pages , and in this page, I have a button [BACK] and I want to redirect the user back to the page he comes from, can anyone give any tips. Back Thanks

Ilia Tapia
  • 629
  • 3
  • 10
  • 23
  • 2
    You can get the help of given [link](https://stackoverflow.com/questions/35446955/how-to-go-back-last-page) . There are many ways to implement back button. `window.history.back();` , use `Location` builtin service , etc. – Denuka May 13 '19 at 09:05
  • Thanks also for your comment – Ilia Tapia May 13 '19 at 09:12

1 Answers1

2

You can use angular Location package back method, it ll redirect the user to the previous page.

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

constructor(
   private location: Location
  ) { }

  goBack() {
    this.location.back();
  }
Nithya Rajan
  • 4,722
  • 19
  • 30