17 lines
470 B
JavaScript
17 lines
470 B
JavaScript
|
/**
|
||
|
* Adds a ng-image-watch attribute, which is a callback invoked when the image is loaded or fails.
|
||
|
*/
|
||
|
angular.module('quay').directive('ngImageWatch', function () {
|
||
|
return {
|
||
|
restrict: 'A',
|
||
|
link: function postLink($scope, $element, $attr) {
|
||
|
$element.bind('error', function() {
|
||
|
$scope.$eval($attr.ngImageWatch)(false);
|
||
|
});
|
||
|
|
||
|
$element.bind('load', function() {
|
||
|
$scope.$eval($attr.ngImageWatch)(true);
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
});
|