Angular 7 location.back without reloading the page

1k views Asked by At

I am using angular 7, and I have a list of items when I click on one item it's go to edit the item page,I put a back button in edit item page, when I click back it's reload the items page and go to the top of the page, How can I go back without reload the page or return back to the last position in the list.

that's what was trying:

<button type="button" (click)="onBack()" style="width:49%" class="btn btn-secondary btn-lg">cancel</button>

onBack() {
    console.log("on back...");
   
    this.location.back();
    return false
}
1

There are 1 answers

6
svyat1s On

Try this.router.navigate(['---Name of your route---']);