簡體   English   中英

離子滑蓋盒不適用於ng-repeat

[英]ionic slide box not working with ng-repeat

我需要使用離子幻燈片框來顯示我的應用程序中的某些圖像。 我用了離子幻燈片盒,它似乎不能與ng-repeat一起使用。

這是我的HTML部分

<ion-view title="Promotions" ng-controller="PromotionsCtrl">


     <ion-content  class="has-header" scroll="true" padding="true">
        <ion-slide-box>

                <ion-slide ng-repeat="obj in promotions">
                        <img ng-src= {{obj.img}}> 

                </ion-slide>

         </ion-slide-box>
    </ion-content>
</ion-view>

我的控制器

.controller('PromotionsCtrl', function($scope, $http, $window, $ionicSlideBoxDelegate,$interval) {





            $http.get(  'http://******.com/B*****/service2.php?q=promotions', { cache: true})
            .then(function(res){

                  $scope.promotions = res.data['top'];


                  $ionicSlideBoxDelegate.update();
                  });
                  })

如果將ng-repeat與幻燈片框一起使用,則必須使用update()。

看這里:

http://ionicframework.com/docs/api/service/%24ionicSlideBoxDelegate/

ionic的新版本.rc4會自動更新幻燈片框。 嘗試更新您的離子庫。

這是我的示例,幻燈片可以運行,但是當委托處理程序更新時,“ does-contunue”的參數不起作用,我仍在尋找解決方案...

的HTML:

<ion-slide-box on-slide-changed="slideHasChanged($index)" does-continue="true" auto-play="true" delegate-handle="image-viewer" style="height:30%;">
        <ion-slide ng-repeat="slide in slideList">
            <div class="box" style="background-image: url('{{slide.url}}');background-size:100% 100%;></div>
    </ion-slide-box>

控制器:

angular.module("myApp.controllers", ["myApp.services"])
.controller("myController", function ($scope, $ionicSlideBoxDelegate, myService,$timeout) {
    $timeout(function(){
        var slideList = myService.getSlides();
        $scope.slideList = slideList;
        $ionicSlideBoxDelegate.$getByHandle('image-viewer').update();
    },2000)
})

服務:

angular.module("myApp.services", [])
.factory("myService", function () {
    return{
        getSlides: function () {
            var slideList = new Array();
            slideList.push("imgs/a.jpg");
            slideList.push("imgs/b.jpg");
            slideList.push("imgs/c.jpg");
            return slideList;
        }
    }
})

正如@Karan所說, update本身就是調用。 但是仍然存在一些問題。 問題中所述,如果數據尚未准備好,您可以禁用滑塊。 那一切都會好起來的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM