Skip to content

Instantly share code, notes, and snippets.

@kmaida
Last active November 3, 2017 14:25
Show Gist options
  • Save kmaida/17eb24221d46152384ef to your computer and use it in GitHub Desktop.
Save kmaida/17eb24221d46152384ef 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()" />
});
}
};
});
@ashwinsingh2007
Copy link

ashwinsingh2007 commented Nov 3, 2017

I dont think this would work in IE, its happening with me .Can you provide any better for IE?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment