Angular Bootstrap Slider - on stop execute function

China☆狼群 提交于 2019-12-07 02:46:25

You can use ngMouseup for that.

<div class="col-md-2 col-md-offset-2" ng-mouseup="executeMe()">
    <slider  ng-model="sliders.sliderValue" min="{{testOptions.min}}" step="{{testOptions.step}}" max="{{testOptions.max}}"></slider>
        {{myFormater(sliders.sliderValue)}}     
</div>

Here's your plunkr modified to demonstrate.

Update

A different approach will be to $watch the slider's value. You can set a timeout so you don't trigger your function while sliding, but only when the value has not changed for some time.

var timeout;
$scope.$watch('sliders.sliderValue', function() {
    if (timeout) {
        $timeout.cancel(timeout);
    }
    timeout = $timeout($scope.executeMe,200);
});

See example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!