Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HMR] TypeError: Cannot read property 'has' of undefined #2

Open
villesau opened this issue Jan 13, 2016 · 6 comments
Open

[HMR] TypeError: Cannot read property 'has' of undefined #2

villesau opened this issue Jan 13, 2016 · 6 comments

Comments

@villesau
Copy link

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. (http://localhost:8080/assets/style-guide.js:67077:63)
at webpack_require (http://localhost:8080/assets/style-guide.js:521:30)
at hotApply (http://localhost:8080/assets/style-guide.js:476:14)
at hotUpdateDownloaded (http://localhost:8080/assets/style-guide.js:269:13)
at hotAddUpdateChunk (http://localhost:8080/assets/style-guide.js:249:13)
at webpackHotUpdateCallback (http://localhost:8080/assets/style-guide.js:5:12)
at http://localhost:8080/assets/0.b36e9a53c6b398f686b1.hot-update.js:1:1

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.

@villesau
Copy link
Author

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.

@villesau
Copy link
Author

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

@yargalot
Copy link
Owner

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 08a5a09 and then throw up an update for you. Happy to do that, didnt realise people were using it ;D

@yargalot
Copy link
Owner

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

@vitaliy-bobrov
Copy link

I've forked this project and added configuration to select app root element.
https://github.com/vitaliy-bobrov/angular-hot-loader

@YonathanB
Copy link

Is there any fix for that??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants