【发布时间】:2017-10-16 00:09:37
【问题描述】:
我有 angular-sly-carousel 指令和一些数据。当用户向下滚动时,我的数据正在添加,所以滚动后我需要重新加载狡猾的轮播选项。
如何检测 ng-repeat 元素的长度何时发生变化?
我的源代码,当我应该检测 ng-repeat 元素长度变化时(不起作用)。
<li sly-horizontal-repeat-simple ng-repeat="game in value | limitTo: gamesLimit track by game.id">
...
</li>
VBET5.directive('slyHorizontalRepeatSimple', function($timeout,$window) {
return {
restrict: 'A',
link: function(scope, el, attrs) {
if (scope.$last === true) {
$timeout(function() {
var cont = $(el[0]);
var frame = $(el[0]).parent();
// Call Sly on frame
$(window).on("resize", function() {
frame.sly("reload");
});
// Watch , if items in ng-repeat change length then reload
scope.$watch('value', function() {
frame.sly("reload"); // I need reload sly when el chang
});
});
}
}
}
});
【问题讨论】:
标签: javascript jquery angularjs angularjs-ng-repeat