I tried the following code in JSBin, the first one could get the canvas object. However, the second one cannot.
JSBin: http://jsbin.com/natavejasa/1/edit?html,js,output
var canvas = $window.document.getElementById('myCanvas');
JSBin: http://jsbin.com/yareb/1/edit?html,js,output
var canvas = $document.getElementById('myCanvas');
So I'm wondering what's the difference between $window.document and $document.
$document is equivalent to angular.element(window.document) - a jqLite wrapper for window.document.
$window.document is the same as window.document - i.e. it is the DOM element document.
The following is true:
$window.document === $document[0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With