简体   繁体   中英

Angular 7 location.back without reloading the page

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
}

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM