There is a slider on angular'e:

<div style="width: 200px;"> <md-slider flex min="0" max="260" ng-model="tax[id]" id="tax[id]" class></md-slider> <input flex type='number' ng-model="tax"> </div> 

Tell me how to transfer the slider data (number) to the JS function? Finding in the controller? I need to perform actions when shifting the slider. Given that ng-model="tax[id]" id="tax[id]" , id random numbers.

  • which function do you want to transfer data to and at what point? - Grundy

1 answer 1

I did not quite understand what "given that ng-model =" tax [id] "id =" tax [id] ", id are random numbers." so:

  1. make a normal ng-model. Let points to the correct object inside the controller.

    ng-model = 'sliderVal'.

  2. add ng-change directive to the slider. in ng-change, call the angular controller method.

    ng-change = 'onSliderChange ()'

  3. in the method, the slider data will be available in sliderVal.

    console.log ($ scope.sliderVal);

  • Displays undefined. - Sergey