0

Using Webpack and HMR, I'd like to reload the AngularJS app without refreshing the browser.

My thinking is to do something like this:

module.hot
&& module.hot.accept('app.js', () => {
    angular.module('app').reload()
})

Where the reload() call will essentially reload the entire AngularJS app from scratch in the same way as if you changed routes in the router.

I don't have any particular preference on the actual solution. My goal is to not require a browser refresh every time an AngularJS file change occurs; rather, I'd like them to occur in the current browser session much like how React Hot Loader functions.

Kevin Ghadyani
  • 6,829
  • 6
  • 44
  • 62
  • I don't think so this can be done. As the new file change would be on the server not on the client browser, hence even if you reload the whole app module you will not be able to fetch the new file change... The reason I am saying this is that browser caches the js files, hence it will reload the old files only which are not having the required changes... – Danish Dec 04 '17 at 10:00
  • With Hot Module Replacement, you are able to reload the file again with the latest update from the server. Even still, I can create another controller with the same name, and it won't override the old one. – Kevin Ghadyani Dec 04 '17 at 20:05

0 Answers0