大家好,我一直坚持这个,我使用blazy
创建了一个指令但似乎它没有在ng-repeat上工作,这是我在指令中的代码
'use strict';
angular.module('angularExerciseApp')
.directive('lazyLoader', function() {
return {
scope: { image: '=imageData' },
template:'<img class="b-lazy" data-blazy="{{image.largeImg}}" data-blazy-small="{{image.smallImg}}" alt="alt-text" />',
restrict: 'EA',
link: function(scope, element, attrs) {
var bLazy = new Blazy({
src: 'data-blazy' ,
breakpoints: [{
width: 420 // Max-width
, src: 'data-blazy-small'
}]
});
}
};
});
并在我的html标签上以这种方式调用指令 结果输出是这个
<div lazy-loader="" ng-repeat="image in imageLists" image-data="image" class="ng-scope ng-isolate-scope">
<img class="b-lazy" data-blazy="assets/images/big-bear2.jpg" data-blazy-small="assets/images/bear-small1.jpg" alt="alt-text">
</div>
我在这里做错了什么?你们可以帮忙吗。谢谢你们,祝你们度过愉快的一天