2

I'm trying to solve a problem. I want that when a perform an action or function in the controller to be saved in the brose history. For example, I want to do this:

  • Type something in a textbox.
  • Click a link to call a function that will set the string I typed to a variable in $scope and save it at the browser history.
  • Do the same as the previous step with a different value.
  • If I click the "back" button from the browser, I want to display the first value I entered.

I have a very simple example of what I want but I don't know what do I have to add to be able to use the "back" and "forward" button from the browser.

http://jsfiddle.net/XMFua/

Thank you very much in advance!

2
  • 1
    If you use angular's routing system, saving to the browser history will be taken care of for you. To solve this problem I would probably use a combination of $routeParam's and manual $route changes in your controller. Commented Aug 17, 2012 at 16:12
  • 1
    Is there a chance for you to explain me how can I do this, please? I think I'm still a newbie to angular. Commented Aug 17, 2012 at 17:42

1 Answer 1

1

You should use the $location service to set the URL. I don't know how to make it work on jsFiddle, however the following should work:

http://jsfiddle.net/marcenuc/BSDxG/

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

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.