昨天我找到了角度旋转木马的解决方案, 但它有一些绑定问题。
每次旋转木马的数据都应该改变,现在这个例子不起作用,但是当我在HTML ng-repeat中的openGame.availableMarketGroups之前添加::时,它的工作原理,但仅限一次绑定。
我该如何解决? 有任何想法吗 ? 感谢
来源
VBET5.directive("owlCarousel", function() {
return {
restrict: 'E',
transclude: false,
link: function (scope) {
scope.initCarousel = function(element) {
// provide any default options you want
var defaultOptions = {
};
var customOptions = scope.$eval($(element).attr('data-options'));
// combine the two options objects
for(var key in customOptions) {
defaultOptions[key] = customOptions[key];
}
// init carousel
var curOwl = $(element).data('owlCarousel');
if(!angular.isDefined(curOwl)) {
$(element).owlCarousel(defaultOptions);
}
scope.cnt++;
};
}
};
})
.directive('owlCarouselItem', [function() {
return {
restrict: 'A',
transclude: false,
link: function(scope, element) {
// wait for the last item in the ng-repeat then call init
if(scope.$last) {
scope.initCarousel(element.parent());
}
}
};
}]);
这是HTML
<data-owl-carousel data-options="{navigation: true, pagination: false, rewindNav : true}">
<div class="market-carousel">
<div owl-carousel-item="" class="carousel-item"
ng-repeat="group in openGame.availableMarketGroups track by group.id">
<span>...</span>
</div>
</div>
</data-owl-carousel>