离子滑块 - 有一种方法可以动态更改间隔

ionic slider - there is a way to change interval dynamiclly

本文关键字:方法 动态 一种      更新时间:2023-09-26

我想根据用户的输入更改间隔:

                <div class="item range range-positive">
                    speed :
                    <i class="icon ion-ios-speedometer-outline"></i>
                    <input ng-model="learnSpeed" type="range" name="volume" min="0" max="20000" value="2000">
                    <i class="icon ion-ios-speedometer"></i>
                </div>

                <ion-slide-box does-continue="true"
                               auto-play="true"
                               slide-interval="{{learnSpeed}}"
                               on-slide-changed="slideHasChanged($index)">
                    <ion-slide ng-repeat="word in allWords" >
                        <div class="box center"
                             ng-class="getRandomColor(word.name)">
                            <h1>{{word.name}}</h1>
                        </div>
                    </ion-slide>
                </ion-slide-box>
</div>

现在发生的事情是 slide-interval="{{learnSpeed}}"从输入中获取速度,但滑块不在此间隔下运行。

有办法吗?

编辑:

当我将此代码添加到控制器时,它也无法正常工作:

controller('learnCtrl', function($scope, $ionicSlideBoxDelegate) {
        $scope.$watch('learnSpeed', function (newValue, oldValue) {
            console.log('oldValue=' + oldValue);
            console.log('newValue=' + newValue);
            $ionicSlideBoxDelegate.update();
        });
});

我认为您可能必须从控制器执行的操作是在用户更改间隔值时从控制器调用$ionicSlideBoxDelegate.update();

$scope.learnSpeed设置为newValue