0

If you work with AJAX and you change the HTML on the server, the new ajax call on client side will fetch you the new html code.

In AngularJS, I need to refresh the page to see the new changes, I cant simply change routes or use $scope.reload() and see the updated HTML.

But the problem is that I loose all my form fields (the $skope is reloaded) when I refresh the page.

I know I can save the scope in cookies or local-storage, I will probably use that in future, but right now, is there any way that I can re-render the html without reloading the page?

4
  • hi, all in $scope. is re-rendered when any is changed. And you can use $watch if you want to spy any scope value, and re-rendered Commented Feb 20, 2017 at 10:16
  • There are a couple of ways you could approach this problem, one way is to bind the whole html to $scope values, changing the bindings will change the page with out the need to reload. But this will create a lot of bindings. Another way is to make a service that will keep your current data and when you reload, just call the data from the service. This is much better then just storing it in cookies or local storage. Commented Feb 20, 2017 at 10:20
  • In theory, you may have a parent scope to store your model. Its prompts for less code overhead then having a service. Commented Feb 20, 2017 at 10:28
  • stackoverflow.com/questions/22217440/… Commented Feb 20, 2017 at 10:30

0

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.