Jason Olson
Jason Olson

Reputation: 1

Force Reload of AngularJS Pages

Is there any way with AngularJS to force a page to refresh after it has been changed. What I mean by this is that I have multiple users actively working in the app but a change is required to the controller.js file. At this point the only way I'm aware of is for them to manually push refresh on the browser. Is there any code that I can use to make it "actively" watch that file for changes and reload when necessary without the users having to manually push refresh?

Upvotes: 0

Views: 639

Answers (2)

michael salmon
michael salmon

Reputation: 416

If you're looking for something to speed up development, then you're probably looking for hot module loading. The solution depends on what version of angular and build tool you're using (e.g. grunt/webpack/npm).

Check out this article for angular 2, but you can find similar solutions for angular 1: http://blog.mgechev.com/2015/10/26/angular2-hot-loader-hot-loading-tooling/

But if you just want to force a page refresh from the client side, you would just call: $window.location.reload()

Upvotes: 0

httpete
httpete

Reputation: 2983

This isn't really an angular problem. You can do polling on the client side with setInterval, hitting the file on the server to trigger a refresh on the client.

Upvotes: 1

Related Questions