3

I am currently working on an application and I need the back button to go back multiple pages. I am familiar with the history.back function as shown below.

//go back to the last view $rootScope.goBack = function(){ history.back(); } 

However, this only goes back one page. Is there anyway for the history to go back further than one step? If so, how can I implement this?

Thank you!

EDIT: I figured I would also share that you can you use the back() feature not only in the html but also in your controller by using $rootScope.back(-2);

1
  • Look into angular's $location Commented Feb 3, 2016 at 14:57

1 Answer 1

6

Just tell it how far to go back:

$rootScope.goBack = function(){ history.go(-3); } 

It's really as simple as that.

Sign up to request clarification or add additional context in comments.

2 Comments

Wow you are genius! Thank you.
If it worked for you, please accept the answer. And, you're welcome.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.