Using Angular How can I watch an image to see if it has finished loading inside a directive?
For example show an alert when the image has been fully retrieved from the URL (not when the div is rendered).
html:
<img src="{{thumbnail}}" image-loading-spinner/>
directive:
directive('imageLoadingSpinner', ['$document', '$parse', function ($document, $parse) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
// get item to watch?
scope.$watch(????, function (newValue) {
//has loaded image url?
alert('got the image!')
)}
}
};
}]).