我是angularjs的新手,我很难使用ng-repeat来处理js插件,例如https://github.com/vasyabigi/angular-slick和其他一些js模块(banner ...)
<slick class="slider lazy">
<div ng-repeat="slide in slides"><div class="image"><img data-lazy="http://vasyabigi.github.io/angular-slick/images/lazyfonz2.png"/></div></div>
</slick
<slick class="slider lazy">
<div><div class="image"><img data-lazy="..."/></div></div>
<div><div class="image"><img data-lazy="..."/></div></div>... >> without ng-repeat, it works
</slick
在slickJs采取行动之前,可能没有足够的时间等待所有图像完成渲染。
该指令确实有$ timeout(https://github.com/vasyabigi/angular-slick/blob/master/dist/slick.js)。
答案 0 :(得分:7)
似乎没有问题。
也许你可以在你的src中显示代码,而不是结果?
HTML:
<slick autoplay="true" autoplaySpeed="500" fade="true">
<div ng-repeat="image in images">
<img data-lazy="{{image}}">
</div>
</slick>
控制器:
var app = angular.module('demo',['slick']);
app.controller('Ctrl', function($scope) {
$scope.images = [
"http://vasyabigi.github.io/angular-slick/images/lazyfonz1.png",
"http://vasyabigi.github.io/angular-slick/images/lazyfonz2.png",
"http://vasyabigi.github.io/angular-slick/images/lazyfonz3.png",
];
});
答案 1 :(得分:3)
您可以添加init-onload = true和data =(urDataArray):
HTML:
<slick autoplay="true" autoplaySpeed="500" fade="true" init-onload=true data="slides">
<div ng-repeat="slide in slides"><img data-lazy="..."/></div>
</slick>
来源: https://github.com/vasyabigi/angular-slick/issues/2
Plunker: http://plnkr.co/edit/fakN9jW5h1ssWaiWaHeN?p=preview