Skip to content

Instantly share code, notes, and snippets.

@mcabreradev
Forked from kmaida/ng-image-onload.js
Created May 6, 2017 03:36
Show Gist options
  • Save mcabreradev/aa27bc13d059f080b0c3a8b216d52cdf to your computer and use it in GitHub Desktop.
Save mcabreradev/aa27bc13d059f080b0c3a8b216d52cdf to your computer and use it in GitHub Desktop.
AngularJS image onload directive
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