0

I am on #loc1. On button click I want to go to #loc3 from #loc1, in such a way that doing back from #loc3 should take me to #loc2. Is that possible in Angularjs?

Thanks in advance.

2
  • have you tried *.history.back()? Commented Mar 16, 2014 at 19:15
  • yes, it takes u back to the last visited link. In fact what I want to do is something like this... $location.path('#loc2').replace(); $scope.apply(); $location.path('#loc3'); Commented Mar 16, 2014 at 19:17

2 Answers 2

1

You can force to go backward without taking in consideration .back() state.

Example:(set for each location to go backward with 1 route)

$location.path('/yourLocation').replace();
Sign up to request clarification or add additional context in comments.

3 Comments

Consider I am on the new employee page. I want to select the department. I do not find the department I m looking for. So I have to go to add department page. What I want to do at this point is first store the information of the employee in HTML storage, generate a temporary url for that and than go to the department page. From there when I say back, the browser should land up on the temporary generated url. I cannot hard code to return to a particular page because I don't know from where the add department page was called. Am I making sense? Let me know if any more information is required.
Do let me know if there is any better way of doing this in angularjs.
I think you should keep somewhere the URLs you are generating.
1

I think there does not exist any method to achieve this. I solved it by forcing the browser to #loc2 from #loc1. From #loc2 I forced it to #loc3, so that the back button takes it back to #loc2.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.