Santhose Kumar
Santhose Kumar

Reputation: 165

How to get the Angular value in javascript function?

Here i want to get the sliderValue in onchange event of javascript function. Currently I am using document.queryselector instead of i want to set it in scope of sliderValue.

Code: <input id="slider" type ="range" min="{{sliderMin}}" onchange="updateSlider()" max="{{sliderMax}}" step="{{sliderStep}}" value="{{sliderValue}}" />

Upvotes: 0

Views: 65

Answers (2)

jbigman
jbigman

Reputation: 1270

I can't agree with Sid response. Angular best practice is to use ngchange:

<input id="slider" type ="range" min="{{sliderMin}}" ng-change="updateSlider(sliderValue)" 
max="{{sliderMax}}" step="{{sliderStep}}" value="{{sliderValue}}" />

Upvotes: 0

Siddharth
Siddharth

Reputation: 7166

Try this:

onchange="angular.element(this).scope().updateSlider(this)"

Upvotes: 2

Related Questions