Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get live values of input range in Angular

Tags:

angular

input

I am using this code to get the value of a slider:

<input type="range" min="30" max="300" value="30" (change)="valueChanged($event)"></div>

Unfortunately, the valueChanged method is triggered on mouse up. How can I be notified of changes continuously as the thumb is dragged?

(onmousemove) does not work.

like image 300
sanjihan Avatar asked Oct 23 '17 10:10

sanjihan


2 Answers

Try like this :

<input type="range" min="30" max="300" value="30" (input)="valueChanged($event.target.value)">

valueChanged(e) {
    console.log('e', e);
}
like image 115
Chandru Avatar answered Nov 12 '22 03:11

Chandru


Here it is you need to use (input) :

<input type="range" min="30" max="300" value="30" (input)="valueChanged($event)">

valueChanged(e) {
  console.log(e.target.value);
}

Here is the link to working example , please have a look :

https://stackblitz.com/edit/input-range-dynamic-value-change

like image 2
Vivek Doshi Avatar answered Nov 12 '22 03:11

Vivek Doshi