Answer the question
In order to leave comments, you need to log in
How to forward model in ng-click callback?
Hello! The situation is the following. I am writing a form for setting the parameters of some object in AngularJS. It has several sliders, which, in addition to the slider, have "+" and "-" buttons, which, respectively, should increment and decrement the value of the model to which the slider is attached. There are N such sliders, and I want to add the less() function to ng-click, which is the same for all "-" buttons, and the more() function, which is the same for all "+" buttons. I want to pass the model as parameters to these functions, and the minimum for the less() function, and the maximum for the more() function, since each slider has different ranges of values.
The values managed by this slider lie in one object, and are its fields, for example:
$scope.results = {
sliders: {
slider_1: X,
slider_2: Y,
slider_3: Z
}
}
<a ng-click="less(results.sliders.slider_1, 0)"> - </a>
Answer the question
In order to leave comments, you need to log in
You can try like this
A in the less method
$scope.less = function(name, num) {
$scope.sliders[name];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question