angularjs指令的代码,看不懂,求高手解释下?

angular.module('cnodejs.directives').directive(

  // Collection-repeat image recycling while loading

  // https://github.com/driftyco/ionic/issues/1742

  'resetImg', function ($document) {

    return {

      restrict: 'A',

      link: function($scope, $element, $attributes) {

        var applyNewSrc = function (src) {

          var newImg = $element.clone(true);


          newImg.attr('src', src);

          $element.replaceWith(newImg);

          $element = newImg;

        };


        $attributes.$observe('src', applyNewSrc);

        $attributes.$observe('ngSrc', applyNewSrc);

      }

    };

  }

);


摇曳的蔷薇
浏览 509回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript