angularjs - 如何清除模态中ngrepeat的索引

angularjs - 如何清除模态中ngrepeat的索引,第1张

我有一个元素列表。 Ever元素附有一个画廊。 我用一个模态来显示每个画廊。它工作得很好。

现在我遇到的问题是关于首先显示的图片。 我们说我在第一个元素中有这个:

Gallery  
 -JrYz8TI7N9ItkAoVtUZ
 -JrYz8TJatqcBm-MBXIK
 -JrYz8TJatqcBm-MBXIL
 -JrYz8TLYhbKEnVEYmBC

这是第二个元素

Gallery
 -JrYz8sPnCEYM-TXHJ9I
 -JrYz8sSLq_mJ6k_tSfG

我想始终从第一个元素开始显示元素。 这不在这里啊。我最终在2个元素的Gallery中得到了3的索引..

你能告诉我如何改变这种行为吗?

这是我的模态推车:

// Dealing with modals for the gallery
$ionicModal.fromTemplateUrl('Cards/image-modal.html', {
    scope: $scope,
    animation: 'slide-in-up'
}).then(function(modal) {
    $scope.modal = modal;
});

$scope.openModal = function(index) {
    $scope.currentGallery = $scope.cards[index].Gallery;
    //console.log('This is'   $scope.cards[index].Gallery);
    console.log("When slide opens "   $scope.slideIndex);
    $scope.modal.show();
    // Important: This line is needed to update the current ion-slide's width
    // Try commenting this line, click the button and see what happens
    $ionicSlideBoxDelegate.update();
};

$scope.closeModal = function() {
    console.log("When slide closes "   $scope.slideIndex);
    $scope.slideIndex = 0;
    console.log("When slide closes and I change it to "   $scope.slideIndex);
    $scope.modal.hide();
};

// Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
    $scope.modal.remove();
    console.log('Modal is destroyed!');
});
// Execute action on hide modal
$scope.$on('modal.hide', function() {
    // Execute action
    console.log('Modal is hidden!');
});
// Execute action on remove modal
$scope.$on('modal.removed', function() {
    // Execute action
    console.log('Modal is removed!');

});
$scope.$on('modal.shown', function() {
    console.log("When slide is on MODAL.SHOW "   $scope.slideIndex);
    console.log('Modal is shown!');
});

// Call this functions if you need to manually control the slides
$scope.next = function() {
    $ionicSlideBoxDelegate.next();
};

$scope.previous = function() {
    $ionicSlideBoxDelegate.previous();
};

// Called each time the slide changes
$scope.slideChanged = function(index) {
    $scope.slideIndex = index;
    console.log("When slide changes "   $scope.slideIndex);
};

这是我的模态代码:

<div class="modal image-modal transparent" ng-click="closeModal()">
    <ion-slide-box on-slide-changed="slideChanged(index)" show-pager="false">
        <ion-slide ng-repeat="item in currentGallery">
            <img ng-src="{{item.picture}}" class="fullscreen-image" />
            <p class="info">{{item.caption}}</p>
        </ion-slide>
    </ion-slide-box>
</div>
你能帮帮忙吗? 我试图在很多地方改变那个指数,我这样做但是它不会影响幻灯片向前发展..

提前谢谢你,

欢呼!

最佳答案:

1 个答案:

答案 0 :(得分:0)

它已经解决了...我基本上用过这个:

var II = $ionicSlideBoxDelegate.currentIndex()   1; 
for (var i = II - 1; i >= 0; i--) { 
    $ionicSlideBoxDelegate.previous(); 
    if ($ionicSlideBoxDelegate.previous() == 0) { 
    break; 
    }; 
}; 

这样,每当我关闭它时,它总会回到开头。干杯!

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复