amp
amp

Reputation: 12372

Go to previous route programmatically

If I have 2 routes and in the markup of the first one I have a link like:

<a href="#/secondPage"/>

and I click on that link (or using the router.nagigate("/secondPage") method) I will go to the second page.

If in that secondPage I have a button that should close the secondPage and return to the previous one. Like the back button of the browser.

How could I do that?

$("#my-button").click(function(){
   //How to navigate to previous page?
});

Upvotes: 1

Views: 582

Answers (1)

Robin Giltner
Robin Giltner

Reputation: 3055

Use router.navigate with "#:back"

router.navigate("#:back");

See sample (Orders and Products tab have back buttons) http://jsbin.com/uvuviWA/3

Upvotes: 1

Related Questions