Here I have to bind the ticks, value, maximum and minimum values dynamically by using angular-bootstrap-slider. But I am unable to bind the values.
CONTROLLER:
var app = angular.module("sliderApp", ['ui.bootstrap-slider']);
app.controller('sliderCtrl', function ($scope, $http) {
var labels =[{ "val": 1, "txt": "one" }, { "val": 2, "txt": "2" }, { "val": 3, "txt": "3" }, { "val": 4, "txt": "4" }, { "val": 5, "txt": "5+" }];
var ticks = [12, 24, 36, 48, 60, 72];
/* maximum value functionality*/
function getMax(labels, prop) {
var max;
for (var i = 0 ; i < labels.length ; i++) {
if (!max || parseInt(labels[i][prop]) > parseInt(max[prop]))
max = labels[i];
}
return max;
}
$scope.sliderMaxVal = getMax(labels, "val").val;
console.log($scope.sliderMaxVal);
/* Minimum value functionality*/
function getMin(labels, prop) {
var min;
for (var i = 0 ; i < labels.length ; i++) {
if (!min || parseInt(labels[i][prop]) < parseInt(min[prop]))
min = labels[i];
}
return min;
}
$scope.sliderMinVal = getMin(labels, "val").val;
$scope.vfg = 1200;
this.sliderValue = 53;
this.sliderLabels = function () {
return labels;
}
this.sliderTicks = function () {
return ticks;
}
this.myFormatter = function (value) {
console.log('value %s', value);
return '<span class="tooltip-header-title">' + value + ' months </span><br> ' + (value - 1) + ' payments + VFG <span class="glyphicon glyphicon glyphicon-tags" aria-hidden="true"></span>';
}
});
HTML:
<div class="col-md-4 .col-xs-4">
<div ng-controller="sliderCtrl as slider">
<slider ng-model="slider.sliderValue" min="{{sliderMinValue}}" step="1" max="72" value="sliderApp.sliderValue" ticks="slider.sliderTicks()" ticks-labels="slider.sliderLabels()" formatter="slider.myFormatter" tooltip="always"></slider>
<p>Value: {{slider.sliderValue}}</p>
<p>VFG: {{vfg}}</p>
</div>
</div>
Now, I have to bind the slider min and max value like {{sliderMinValue}} and {{sliderMaxValue}} instead of static values. But when I do this, I am getting this type of error as shown in below figure:
Plunker: https://plnkr.co/edit/mSuWAtL89DEDE88pwAm5?p=preview