javascript - Load event of an element with a directive -
suppose have made new directive in angularjs attribute restriction, my-directive. suppose have following html code:
<img src="..." my-directive /> now, load event of <img> triggered when code of my-directive executed , dom completly loaded, or when information of natively <img> tag loaded (for example src data, style, ...)?
i want know information because want understand effect intercept load event inside code of directive.
as comment mentions, you'll want use pre-compile link funciton, aided using ng-src instead of native src attribute, allows angular insert process. can interception prior compilation so:
module.directive('interceptimg',function(){ //other functions on directive template , controller compile:{ return: { pre: function prelink(scope, ielement, iattrs, controller){ //you can listen/bind events here accessing ielement } } } }) checkout docs $compile
Comments
Post a Comment