ng-onload
ng-onload copied to clipboard
Not working when iframe src is about:blank
The ng-onload function is not called when the iframe source is set to "about:blank"
Can you describe the use case? You start off with a blank and then populate it programmatically, or?
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
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.