gpt4 book ai didi

javascript - angularjs ng-repeat的猫头鹰旋转木马问题

转载 作者:行者123 更新时间:2023-11-30 11:56:10 27 4
gpt4 key购买 nike

拜托,我正在为我的轮播使用猫头鹰轮播。我的旋转木马与这里的非常相似 http://thebootstrapthemes.com/live/thebootstrapthemes-zenclassified/ .我遇到了类似的解决方案 Here和这里 。然后我在下面的 Controller 中添加了一个类似的指令。

.directive('owlCarousel', function(){
return {
restrict: 'E',
transclude: false,
link: function (scope) {
scope.initCarousel = function(element) {
// provide any default options you want
var defaultOptions = {
autoplay:true,
autoplayTimeout:2500,
loop:false,nav : true,
responsiveClass:true,
margin: 30,
responsive:{
0:{items:1},
767:{items:3},
992:{items:4}
}
};
var customOptions = scope.$eval($(element).attr('data-options'));
// combine the two options objects
for(var key in customOptions) {
defaultOptions[key] = customOptions[key];
}
// init carousel
$(element).owlCarousel(defaultOptions);
};
}
};
}).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());
}
}
};
}]);

以上对我有用,除了。最后一个元素的高度增加超过下面的其他元素。

您可以看到上面显示的最后一项。请问我该如何解决,原因是什么?任何帮助将不胜感激。

最佳答案

试试这个

.directive('owlCarousel', function(){
return {
restrict: 'EA',
transclude: false,
link: function (scope, element, attrs) {
scope.initCarousel = function() {
// provide any default options you want
var defaultOptions = {
autoplay:true,
autoplayTimeout:2500,
loop:false,nav : true,
responsiveClass:true,
margin: 30,
responsive:{
0:{items:1},
767:{items:3},
992:{items:4}
}
};
$(element).owlCarousel(defaultOptions);
};
}
};
}).directive('owlCarouselItem',[function() {
return function(scope) {
if (scope.$last) {
scope.initCarousel();
}
};
}]);

请引用这个问题 Here It what worked for me.

关于javascript - angularjs ng-repeat的猫头鹰旋转木马问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37893225/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com