Code Monkey home page Code Monkey logo

Comments (9)

chieffancypants avatar chieffancypants commented on September 26, 2024

The problem with this approach is that if ng-app is not defined on body (or a parent such as the html element), things start to break down. This is why I use $rootElement, because it is guaranteed to be within scope of ng-app.

Learned this the hard way: chieffancypants/angular-loading-bar#12

from angular-hotkeys.

chieffancypants avatar chieffancypants commented on September 26, 2024

Just checked this out with the latest (v1.3.0-build.2601+sha.ede9984), and it seemed to work fine. Can you try it again?

from angular-hotkeys.

marshall007 avatar marshall007 commented on September 26, 2024

Ok so the problem is that I manually bootstrap the application on document so in my case $rootElement is document and can't be appended to. From the $rootElement docs:

The root element of Angular application. This is either the element where ngApp was declared or the element passed into angular.bootstrap.

What are your thoughts on using $document[0].body?

from angular-hotkeys.

chieffancypants avatar chieffancypants commented on September 26, 2024

Same issue applies though -- If someone declares ng-app on a child element of body, then the hotkeys div will be placed outside of ngApp's scope. I haven't looked into the full implications of this, but it has caused issues before with things like ngAnimate.

I'm thinking the only real solution is to check if the $rootElement is the document, and if so, appending it to body. May have to check if other elements will have the same issue (not sure if it's possible to bootstrap the app on window, for example)

from angular-hotkeys.

gustavohenke avatar gustavohenke commented on September 26, 2024

@chieffancypants can I send a PR to this fix? It's interesting to me to see this issue fixed and it's rather simple to do.

from angular-hotkeys.

chieffancypants avatar chieffancypants commented on September 26, 2024

of course! Please do, and I'll review. Please keep in mind, if it does not address the issues above, I'll be unable to merge, but otherwise I appreciate the help!

from angular-hotkeys.

amcdnl avatar amcdnl commented on September 26, 2024

Im getting this too, I resolved it by replacing $rootElement with document.body on https://github.com/chieffancypants/angular-hotkeys/blob/master/src/hotkeys.js#L164

from angular-hotkeys.

gustavohenke avatar gustavohenke commented on September 26, 2024

@amcdnl Let's wait until #29 gets merged in, so the fix is global :)

from angular-hotkeys.

shabalin avatar shabalin commented on September 26, 2024

I can confirm that for

    "jquery": "2.0.3",
    "angular": "1.2.15",
    "angular-hotkeys": "chieffancypants/angular-hotkeys#~1.2.3"

and manual application bootstrap

 angular.bootstrap(document, ["Speca"]);

problem exists and following error message is appeared in the console:

Uncaught TypeError: Cannot read property 'createDocumentFragment' of null 

I worked that around by passing document.body node instead of document

 angular.bootstrap(document.body, ["Speca"]);

PS I also noticed that If I exclude jQuery dependency the error disappears as well, but this is not an option for me.

from angular-hotkeys.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.