Q:

How to access iframe by id in AngularJS?

How can I get reference of the iframe element with AngularJS ?
<div>
   <iframe id="myframe" ...>
</div>

mycontroller.$inject = ['$document'];

function mycontroller ($document) {
    console.log($document.getElementById("myframe")); //always null
}

I can see the iframe, but the reference lookup always prints null. Why?

A:

The $document service returns an array.
You should use it like his :
console.log($document[0].getElementById("myframe"));

Please, see the jsfiddled solution : https://jsfiddle.net/jjbw1z8j/2/

