JAVASCRIPT   128
error src js
Guest on 8th June 2022 09:16:48 AM


  1. LimoLabsIcabbiApp.directive('errorSrc', function() {
  2.     return {
  3.         link: function(scope, element, attrs) {
  4.            
  5.             element.bind('error', function() {
  6.                 if (attrs.src != attrs.errorSrc) {
  7.                     attrs.$set('src', attrs.errorSrc);
  8.                 }
  9.             });
  10.  
  11.             attrs.$observe('ngSrc', function(value) {
  12.                 if (!value && attrs.errorSrc) {
  13.                     attrs.$set('src', attrs.errorSrc);
  14.                 }
  15.             });
  16.            
  17.         }
  18.     }
  19. });

Raw Paste

Login or Register to edit or fork this paste. It's free.