ng-onload icon indicating copy to clipboard operation
ng-onload copied to clipboard

Not working when iframe src is about:blank

Open sneps85 opened this issue 8 years ago • 3 comments

The ng-onload function is not called when the iframe source is set to "about:blank"

sneps85 avatar Jan 10 '17 07:01 sneps85

Can you describe the use case? You start off with a blank and then populate it programmatically, or?

mikaturunen avatar Jan 10 '17 07:01 mikaturunen

Yes, indeed..

I start with:

<iframe src="about:blank" id="myFrame" ng-onload="populate()"></iframe">

and then on the JS part i get the iframe by id, open it, write to it and then close it. But the $scope.populate() function is only called, when i put something else in the iframe src parameter like www.google.com

sneps85 avatar Jan 10 '17 07:01 sneps85

That essentially means that the elements "load" -event is not called on change, you are updating the element.

ng-onload hooks to the 'load' event of the element. This is intended behaviour at this point: https://github.com/mikaturunen/ng-onload/blob/master/lib/ng-onload.js#L29

I could look into also adding a change listener but there is no guarantee the HTML will trigger the function. I will have to test it. I'm assuming it would but not sure.

mikaturunen avatar Jan 10 '17 08:01 mikaturunen