基本思想是创建一个指令并将其作为属性添加到img标签。
JS:
app.directive('imageonload', function() { return { restrict: 'A', link: function(scope, element, attrs) { element.bind('load', function() { alert('image is loaded'); }); element.bind('error', function(){ alert('image could not be loaded'); }); } };});HTML:
<img ng-src="{{src}}" imageonload />


