Comments (9)
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.
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.
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.
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.
@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.
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.
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.
@amcdnl Let's wait until #29 gets merged in, so the fix is global :)
from angular-hotkeys.
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)
- Translation of keys
- Programmatically open hotkeys dialog HOT 2
- Hotkey does not fire when changing routes in ngRoute HOT 1
- Can we trigger the Hotkey for particular element., HOT 1
- Improve Documentation of directive-based hotkeys HOT 1
- cheatsheet not displayed HOT 2
- Wildcard combo?
- Hotkey using only slash does not apper on the cheatsheet HOT 1
- hotkey with ctrl+alt++ is not working HOT 1
- Delete all binded hotkey HOT 1
- Compatibility AZERTY
- hotkey with mod+w closes the browser tab HOT 1
- In callback function array is not visible from scope HOT 3
- new hotkey not adding
- Is this a AMD module?
- Error: [$sce:unsafe] Attempting to use an unsafe value in a safe context when configuring templateHeader
- iframe binding issue HOT 3
- Change the cheatsheet Shift icon (up arrow) to the word SHIFT. HOT 1
- How to test ESC press in angualr unit test? HOT 2
- Hotkeys are not working on text input focus HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-hotkeys.