input [range] is one of the AngularJS input directive in module ng.
AnguarJS directive input [range] is used to create an HTML range input with validation and transformation.
The model for the range input should be a Number.
Some following values for Angular:
As the element value must reflect the current model value, a range input will set the ngModel expression to the value that the browser to be set for the input element.
For ex, <input type=”range” ng-model=”model.value”>
If sets the value for model.value=null, the browser will set the input to ‘50’ as well as angular will set the model to 50.
It means the model for range will directly set to 50 after ngmodel has been initialized.
It does not affect the changes to the model value.
Checked attribute will be set on the element when the expression is truthy.
Sample coding for input [range] directive in AngularJS
Code Explanation input [range] directive in AngularJS:
The ng-app specifies the root element (“myApp”) to define AngularJS application.
ng-controller specifies the application controller in AngularJS the controller value is given as “rangeCtrl”.
“range” is declare the type value of the <input> tag.
min parameter is used to declare the min value in expression.({{min}})
max parameter is used to declare the max value in expression.({{max}})
“range” is declare the type value of the <input> tag.
ng-min is used to declare the min value in AngularJS.(“min”)
ng-max is used to declare the max value in AngularJS(“max”)
“number” is declare the type value of the <input> tag.
The ng-model bind an input field value to AngularJS application variable (“min”).
The ng-model bind an input field value to AngularJS application variable (“max”).
Form.range.$valid to checks the correct range format or not. If the user set the range in the input field then the output will be displays as true otherwise false.
Form.range.$error to check whether the valid range format or not .If the range specified in error it throw an exception (Like “required”=”true) otherwise it is an empty curly braces ( { } ).
The values are given as value, min and max in the scope object.
Sample Output input [range] directive in AngularJS:
If the user set the range in the input field.
The output displays as value=75.
The output displays true because it is consider as a valid range value.
The output displays empty curly braces it means does not thrown any error.
Browser Support for input [range] directive in AngularJS:
Yes
No
Yes
Yes
Yes
Tips and Notes
input [range] does not set the min and max attributes, because it is not compatible with ngMax, ngMin and ngStep.
It means the browser will not automatically adjust the input value , and will always assume min=0, max=100 and step=1
Related Searches to angularjs input[range] directive
angularjs min max validationangularjs input validation exampleangular input number stepng-max not workingangularjs input min max validationangular range definitionng-min not workingangular2 input rangeng-stepangularjs tutorials
angularjs min max validationangularjs input validation exampleangular input number stepng-max not workingangularjs input min max validationangular range definitionng-min not workingangular2 input rangeng-step