javascript - How to store and retrieve search parameters in angularjs? -


I have an angular app where I sometimes want to:

  • Store the currently entered form Variable for the page currently shown can be either a search term or other user input.
  • If the user goes back in history, make sure the same search parameters are used again

I did ngRoute, state provider and HTML history and do this Did not find a good way It looks like something that should be quite common, so I think that I do not understand how to do it.

itemprop = "text">

Based on what you are describing, I can see that such a thing can be done.

Which is the most in the browser, anyway it is also for this. This would mean that you store using a name / value pair.

Here's a quick example:

  var searchParameters = {filters: ['recent'], searchString: bacon '} // store price (s) localStorage.setItem ('SearchParameters', JSON.stringify (searchParameters)); // Retrieve prices searchParameters = JSON.parse (localStorage.getItem ('searchParameters')); // Stop the value localStorage.removeItem ('searchParameters');  

Depending on your flow, you can use the browser history stack. So if anyone searches for Bacon then you can call it on the page? With Query = bacon , this will allow you to easily maintain history and easy access to the back button. At the end of the day, all this really comes down to how your application has been set, what is this the best option? Other ways can also be done on the basis of these requirements. For example, if you need to synchronize all the devices then the server side component will need to store and retrieve the values.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -