@@ -1027,6 +1027,148 @@ var inputType = {
1027
1027
*/
1028
1028
'radio' : radioInputType ,
1029
1029
1030
+ /**
1031
+ * @ngdoc input
1032
+ * @name input[range]
1033
+ *
1034
+ * @description
1035
+ * Native range input with validation and transformation.
1036
+ *
1037
+ * <div class="alert alert-warning">
1038
+ * <p>
1039
+ * In v1.5.9+, in order to avoid interfering with already existing, custom directives for
1040
+ * `input[range]`, you need to let Angular know that you want to enable its built-in support.
1041
+ * You can do this by adding the `ng-input-range` attribute to the input element. E.g.:
1042
+ * `<input type="range" ng-input-range ... />`
1043
+ * </p><br />
1044
+ * <p>
1045
+ * Input elements without the `ng-input-range` attibute will continue to be treated the same
1046
+ * as in previous versions (e.g. their model value will be a string not a number and Angular
1047
+ * will not take `min`/`max`/`step` attributes and properties into account).
1048
+ * </p><br />
1049
+ * <p>
1050
+ * **Note:** From v1.6.x onwards, the support for `input[range]` will be always enabled and
1051
+ * the `ng-input-range` attribute will have no effect.
1052
+ * </p><br />
1053
+ * <p>
1054
+ * This documentation page refers to elements which have the built-in support enabled; i.e.
1055
+ * elements _with_ the `ng-input-range` attribute.
1056
+ * </p>
1057
+ * </div>
1058
+ *
1059
+ * The model for the range input must always be a `Number`.
1060
+ *
1061
+ * IE9 and other browsers that do not support the `range` type fall back
1062
+ * to a text input without any default values for `min`, `max` and `step`. Model binding,
1063
+ * validation and number parsing are nevertheless supported.
1064
+ *
1065
+ * Browsers that support range (latest Chrome, Safari, Firefox, Edge) treat `input[range]`
1066
+ * in a way that never allows the input to hold an invalid value. That means:
1067
+ * - any non-numerical value is set to `(max + min) / 2`.
1068
+ * - any numerical value that is less than the current min val, or greater than the current max val
1069
+ * is set to the min / max val respectively.
1070
+ * - additionally, the current `step` is respected, so the nearest value that satisfies a step
1071
+ * is used.
1072
+ *
1073
+ * See the [HTML Spec on input[type=range]](https://www.w3.org/TR/html5/forms.html#range-state-(type=range))
1074
+ * for more info.
1075
+ *
1076
+ * This has the following consequences for Angular:
1077
+ *
1078
+ * Since the element value should always reflect the current model value, a range input
1079
+ * will set the bound ngModel expression to the value that the browser has set for the
1080
+ * input element. For example, in the following input `<input type="range" ng-input-range ng-model="model.value">`,
1081
+ * if the application sets `model.value = null`, the browser will set the input to `'50'`.
1082
+ * Angular will then set the model to `50`, to prevent input and model value being out of sync.
1083
+ *
1084
+ * That means the model for range will immediately be set to `50` after `ngModel` has been
1085
+ * initialized. It also means a range input can never have the required error.
1086
+ *
1087
+ * This does not only affect changes to the model value, but also to the values of the `min`,
1088
+ * `max`, and `step` attributes. When these change in a way that will cause the browser to modify
1089
+ * the input value, Angular will also update the model value.
1090
+ *
1091
+ * Automatic value adjustment also means that a range input element can never have the `required`,
1092
+ * `min`, or `max` errors.
1093
+ *
1094
+ * However, `step` is currently only fully implemented by Firefox. Other browsers have problems
1095
+ * when the step value changes dynamically - they do not adjust the element value correctly, but
1096
+ * instead may set the `stepMismatch` error. If that's the case, the Angular will set the `step`
1097
+ * error on the input, and set the model to `undefined`.
1098
+ *
1099
+ * Note that `input[range]` is not compatible with `ngMax`, `ngMin`, and `ngStep`, because they do
1100
+ * not set the `min` and `max` attributes, which means that the browser won't automatically adjust
1101
+ * the input value based on their values, and will always assume min = 0, max = 100, and step = 1.
1102
+ *
1103
+ * @param ngInputRange The presense of this attribute enables the built-in support for
1104
+ * `input[range]`.
1105
+ * @param {string } ngModel Assignable angular expression to data-bind to.
1106
+ * @param {string= } name Property name of the form under which the control is published.
1107
+ * @param {string= } min Sets the `min` validation to ensure that the value entered is greater
1108
+ * than `min`. Can be interpolated.
1109
+ * @param {string= } max Sets the `max` validation to ensure that the value entered is less than `max`.
1110
+ * Can be interpolated.
1111
+ * @param {string= } step Sets the `step` validation to ensure that the value entered matches the `step`
1112
+ * Can be interpolated.
1113
+ * @param {string= } ngChange Angular expression to be executed when the ngModel value changes due
1114
+ * to user interaction with the input element.
1115
+ * @param {expression= } ngChecked If the expression is truthy, then the `checked` attribute will be set on the
1116
+ * element. **Note** : `ngChecked` should not be used alongside `ngModel`.
1117
+ * Checkout {@link ng.directive:ngChecked ngChecked} for usage.
1118
+ *
1119
+ * @example
1120
+ <example name="range-input-directive" module="rangeExample">
1121
+ <file name="index.html">
1122
+ <script>
1123
+ angular.module('rangeExample', [])
1124
+ .controller('ExampleController', ['$scope', function($scope) {
1125
+ $scope.value = 75;
1126
+ $scope.min = 10;
1127
+ $scope.max = 90;
1128
+ }]);
1129
+ </script>
1130
+ <form name="myForm" ng-controller="ExampleController">
1131
+
1132
+ Model as range: <input type="range" ng-input-range name="range" ng-model="value" min="{{min}}" max="{{max}}">
1133
+ <hr>
1134
+ Model as number: <input type="number" ng-model="value"><br>
1135
+ Min: <input type="number" ng-model="min"><br>
1136
+ Max: <input type="number" ng-model="max"><br>
1137
+ value = <code>{{value}}</code><br/>
1138
+ myForm.range.$valid = <code>{{myForm.range.$valid}}</code><br/>
1139
+ myForm.range.$error = <code>{{myForm.range.$error}}</code>
1140
+ </form>
1141
+ </file>
1142
+ </example>
1143
+
1144
+ * ## Range Input with ngMin & ngMax attributes
1145
+
1146
+ * @example
1147
+ <example name="range-input-directive-ng" module="rangeExample">
1148
+ <file name="index.html">
1149
+ <script>
1150
+ angular.module('rangeExample', [])
1151
+ .controller('ExampleController', ['$scope', function($scope) {
1152
+ $scope.value = 75;
1153
+ $scope.min = 10;
1154
+ $scope.max = 90;
1155
+ }]);
1156
+ </script>
1157
+ <form name="myForm" ng-controller="ExampleController">
1158
+ Model as range: <input type="range" ng-input-range name="range" ng-model="value" ng-min="min" ng-max="max">
1159
+ <hr>
1160
+ Model as number: <input type="number" ng-model="value"><br>
1161
+ Min: <input type="number" ng-model="min"><br>
1162
+ Max: <input type="number" ng-model="max"><br>
1163
+ value = <code>{{value}}</code><br/>
1164
+ myForm.range.$valid = <code>{{myForm.range.$valid}}</code><br/>
1165
+ myForm.range.$error = <code>{{myForm.range.$error}}</code>
1166
+ </form>
1167
+ </file>
1168
+ </example>
1169
+
1170
+ */
1171
+ 'range' : rangeInputType ,
1030
1172
1031
1173
/**
1032
1174
* @ngdoc input
0 commit comments