-
-
Save mcabreradev/aa27bc13d059f080b0c3a8b216d52cdf to your computer and use it in GitHub Desktop.
AngularJS image onload directive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.module['myApp'].directive('imageOnload', function() { | |
return { | |
restrict: 'A', | |
link: function(scope, element, attrs) { | |
element.bind('load', function() { | |
// call the function that was passed | |
scope.$apply(attrs.imageOnload); | |
// usage: <img ng-src="src" image-onload="imgLoadedCallback()" /> | |
}); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment