好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

angular img标签使用err-src

在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);
      }
    });
  }
}
});

查看更多关于angular img标签使用err-src的详细内容...

  阅读:35次