This does not work
<img class="my-image" preload-image default-image="default.jpg" fallback-image="error.jpg" ng-src="my-image.jpg"/>
This works
<img class="my-image" ng-src="my-image.jpg"/>
my-image.directive.js
function myImage () {
return {
restrict: 'C',
link: function (scope, $element, attrs) {
$element.on('load error', function () { // this line is not triggered
doSomethingWhenTheImageIsLoaded();
});
}
};
}
myImage.$inject = [];
angular.module('chat').directive('myImage', myImage);
This does not work
<img class="my-image" preload-image default-image="default.jpg" fallback-image="error.jpg" ng-src="my-image.jpg"/>
This works
<img class="my-image" ng-src="my-image.jpg"/>
my-image.directive.js