在directive中定义组件,在ng-src错误时,调用err-src.

app.directive('errSrc',function() {
  return {
    link: function(scope, element, attrs) {
      if(attrs.src='undefined'){

        attrs.$set('src', attrs.errSrc);

      }
      element.bind('error', function() {
      if (attrs.src != attrs.errSrc) {
        attrs.$set('src', attrs.errSrc);
      }
    });
  }
}
});

相关文章:

  • 2022-02-19
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
  • 2022-12-23
  • 2021-04-10
  • 2022-02-16
  • 2022-12-23
猜你喜欢
  • 2022-03-09
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案