Reputation: 1113
I am confused on why $document
is not working in my run function but document
is.
This works:
.run(function($rootScope, $state, $stateParams) {
document.addEventListener('deviceready', checkConnection, false);
//more code below
This does not work:
.run(function($document, $rootScope, $state, $stateParams) {
$document.addEventListener('deviceready', checkConnection, false);
//more code below
What am I missing here to use the angular $document
service?
Thanks!
Upvotes: 0
Views: 69
Reputation: 136174
You wanted to attach DOM event to document
object while registering event listener to it.
But $document
does have that object on 0
th index & with its length, So you could easily get document
from $document by doing $document[0]
.
For making if more better using angular jQLite API you could use .on
$document.on('deviceready', checkConnection, false);
Upvotes: 2