Angular-HMR
Angular-HMR copied to clipboard
[HMR] TypeError: Cannot read property 'has' of undefined
I tried to apply the angular-HMR to the existing project and got this error:
[HMR] TypeError: Cannot read property 'has' of undefined
at HotAngular.reloadState (http://localhost:8080/assets/style-guide.js:61911:26)
at module.exports as directive
at Object.
Any advices, or is it a bug? The library seems to understand the angular directives and logs them into console, so i guess there is just a small bug somewhere.
the actual line it crashes is the last one of these:
HotAngular.prototype.reloadState = function() {
var elm = angular.element(document.querySelector('[ng-app]'));
if (elm) {
if (elm.injector().has('$state')) {
So elem.injector() returns undefined.
i have a fork where i changed .querySelector('[ng-app]') to .querySelector('body') which fixed the problem in my case. I could make a pull request of it but this repo seems to live it's own life i think.. The current version of the repo seems to be pretty broken so i didn't start to fix that, but the one is in NPM.
https://github.com/villesau/Angular-HMR
Hey @villesau,
The previous release would be a bit behind, if You make a pull request I can fix up the rest thats broken, can always take it back to this commit https://github.com/yargalot/Angular-HMR/commit/08a5a09f548a8e7a907c1345a4094dbb9daf501d and then throw up an update for you. Happy to do that, didnt realise people were using it ;D
But yeh, I imagine your manually bootstrapping the app instead of using ng-app? can use the body / html as a fallback if ng-app doesnt exist
I've forked this project and added configuration to select app root element. https://github.com/vitaliy-bobrov/angular-hot-loader
Is there any fix for that??