How to display text in place of number in angularjs materials silder
<p ng-bind="val" ng-init="val=20"></p>
<div class="slider" ui-jq="slider" ng-slider-model="val" ui-options="sliderOpt4"></div>
</div>
Here is the an directive you can access and show the value of controller value ..with html and css
.directive('ngSliderModel', ['$parse', function($parse) {
return {
scope: {
ngSliderModel: '=',
uiOptions: '='
},
restrict: 'A',
required: ['ngSliderModel'],
link: function(scope, element, attrs) {
// check there is uiOption or not
var options = ('uiOptions' in attrs) ? scope.uiOptions : {};
// get the value of ngSlider Model
var val = scope.ngSliderModel;
// if value is range [15,25] then return values for uiOptions propertyName else value for singles
var propName = (angular.isArray(val)) ? 'values' : 'value';
/* if you want to slide when the scope value changed not from slider...
watch the ngSliderModel attribute
*/
scope.$watch('ngSliderModel', function(newValue){
element.slider(propName, newValue);
});
// set value for options
options[propName] = val;
// binding slide event
element.bind('slide', function() {
// Read the current value
var value = element.slider('option', propName);
scope.$apply(function() {
// Apply the value to scope
scope.ngSliderModel = value;
});
});
}
};
}]);
Unfortunately that functionality is not supported as it's not technically part of the material spec for sliders.
For a likert scale you should consider the selection controls spec of material. Otherwise, you can get away with it in Angular Material by using a horizontal row of radio buttons.
Angular Material does not support it.
for more detail check slider.js of angular-material module
function SliderDirective($$rAF, $window, $mdAria, $mdUtil, $mdConstant, $mdTheming, $mdGesture, $parse, $log) {
return {
scope: {},
require: '?ngModel',
template:
'<div class="md-slider-wrapper">\
<div class="md-track-container">\
<div class="md-track"></div>\
<div class="md-track md-track-fill"></div>\
<div class="md-track-ticks"></div>\
</div>\
<div class="md-thumb-container">\
<div class="md-thumb"></div>\
<div class="md-focus-thumb"></div>\
<div class="md-focus-ring"></div>\
<div class="md-sign">\
<span class="md-thumb-text"></span>\
</div>\
<div class="md-disabled-thumb"></div>\
</div>\
</div>',
compile: compile
};
inside this code
<span class="md-thumb-text"></span>
is used to render the slider's range number. and following method is used to render it
function postLink(scope, element, attr, ngModelCtrl){
}
you can modify function's content like this
var _values = ["very low", "low", "average", "good", "best"];
thumbText.text( _values[ngModelCtrl.$viewValue] );
to render text rather integer value.
Angualar-material dose not support this feature right now how ever you can do this thing by writing your own logic or you can create your own slider.