Question

In my project I am using angular $routeProvider in order to dynamically load pages in a ng-view area. The pages are getting loaded correctly in the ng-view and they are also cached so that the next time they are loaded instantly without performing a request to the server.

The thing is that there are some pages where I have a form with initial values loaded from the server. I change those values and submit them back to server with an Ajax post.

When I change the ng-view with another page and change it back to the form page, I don't see the updated values but I see the old ones.

How can I remove this specific page from the cache after the form is submitted so the whole page is requested again from the server?

Is there another workaround this issue?

Thank you!

Was it helpful?

Solution

We handle this by having all our our ng-view areas strictly as static HTML. All dynamic information or 'data' is retrieved separately from the server as JSON.

This allows us to easily control the information being displayed in a particular view simply by manipulating the object the view area is bound to for it's data. For views that are used frequently, this is more efficient as the cached view area never needs to be refreshed.

In your case, your initial form values should be retrieved separately and bound to the form.

OTHER TIPS

you can clear your scope data related to the form perhaps since they are all stored that way. if you have chrome, use angularjs batarang to see where your form values are stored in the scope.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top