Skip to content

Instantly share code, notes, and snippets.

@ColdFire87
Created May 26, 2017 09:45
Show Gist options
  • Save ColdFire87/5ce2b7a613776ba2203172d36959e0f1 to your computer and use it in GitHub Desktop.
Save ColdFire87/5ce2b7a613776ba2203172d36959e0f1 to your computer and use it in GitHub Desktop.
<!-- for example -->
<img ng-src="{{ flaky.image }}" ng-error="tellServerItsBroken(this)">
// FROM https://github.com/angular/angular.js/issues/8759
angular.module('app')
.directive('img', function () {
return {
restrict: 'E',
link: function (scope, el, attr) {
el.on('error', function () {
if (attr['ngError']) {
scope.$eval(attr['ngError'])
}
})
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment