AngularJS滑块自定义值

时间:2016-02-25 09:54:49

标签: javascript angularjs

我创建了一个滑块,但我想要不同范围内的值。 This is how the slider looks. 但是,我想要的是1 Lakh,2 Lakhs,3 Lakhs,5 Lakhs,10 Lakhs和10 Lakhs。如何设置也打印文本的值集。我已将rg-slider与我的代码结合起来。

<rg-slider
    tracker-class="my-tracker rg-tracker-with-animation"
    navigator-class="my-navigator"
    bound-var="sliderValue"
    show-navigator="true"
    navigator-from="1"
    navigator-to="16">
</rg-slider>

1 个答案:

答案 0 :(得分:4)

它看起来并不像你正在使用的rg-slider指令中内置的那样。我建议您使用更多功能的东西,而不是让事情变得复杂:

http://angular-slider.github.io/angularjs-slider/index.html

<强>更新

将以下代码复制到此jsfiddle中,然后点击“运行:

<强> JS

var app = angular.module('rzSliderDemo', ['rzModule', 'ui.bootstrap']);

app.controller('MainCtrl', function ($scope, $rootScope, $timeout, $modal) {

   //Slider with ticks and values
    $scope.slider_ticks_values = {
        value: 0,
        options: {
            ceil: 5,
            floor: 0,
            showTicksValues: true,
            translate: function (value) {
                return value + ' Lakhs';
            }
        }
    };
});

<强> HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.14.3/ui-bootstrap-tpls.js"></script>
<script src="https://rawgit.com/rzajac/angularjs-slider/master/dist/rzslider.js"></script>
<div ng-app="rzSliderDemo">
    <div ng-controller="MainCtrl" class="wrapper">
        <header>
             <h1>AngularJS Touch Slider</h1>
        </header>
        <article>
             <h2>Slider with ticks and values</h2>

            <rzslider rz-slider-model="slider_ticks_values.value" rz-slider-options="slider_ticks_values.options"></rzslider>
        </article>
    </div>
</div>