|
9 | 9 | */
|
10 | 10 |
|
11 | 11 | var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
|
12 |
| -var EMAIL_REGEXP = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,6}$/; |
| 12 | +var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*$/i; |
13 | 13 | var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/;
|
14 | 14 |
|
15 | 15 | var inputType = {
|
@@ -309,28 +309,35 @@ var inputType = {
|
309 | 309 | * @param {string=} name Property name of the form under which the control is published.
|
310 | 310 | * @param {string=} ngChange Angular expression to be executed when input changes due to user
|
311 | 311 | * interaction with the input element.
|
| 312 | + * @param {string} ngValue Angular expression which sets the value to which the expression should |
| 313 | + * be set when selected. |
312 | 314 | *
|
313 | 315 | * @example
|
314 | 316 | <doc:example>
|
315 | 317 | <doc:source>
|
316 | 318 | <script>
|
317 | 319 | function Ctrl($scope) {
|
318 | 320 | $scope.color = 'blue';
|
| 321 | + $scope.specialValue = { |
| 322 | + "id": "12345", |
| 323 | + "value": "green" |
| 324 | + }; |
319 | 325 | }
|
320 | 326 | </script>
|
321 | 327 | <form name="myForm" ng-controller="Ctrl">
|
322 | 328 | <input type="radio" ng-model="color" value="red"> Red <br/>
|
323 |
| - <input type="radio" ng-model="color" value="green"> Green <br/> |
| 329 | + <input type="radio" ng-model="color" ng-value="specialValue"> Green <br/> |
324 | 330 | <input type="radio" ng-model="color" value="blue"> Blue <br/>
|
325 |
| - <tt>color = {{color}}</tt><br/> |
| 331 | + <tt>color = {{color | json}}</tt><br/> |
326 | 332 | </form>
|
| 333 | + Note that `ng-value="specialValue"` sets radio item's value to be the value of `$scope.specialValue`. |
327 | 334 | </doc:source>
|
328 | 335 | <doc:scenario>
|
329 | 336 | it('should change state', function() {
|
330 |
| - expect(binding('color')).toEqual('blue'); |
| 337 | + expect(binding('color')).toEqual('"blue"'); |
331 | 338 |
|
332 | 339 | input('color').select('red');
|
333 |
| - expect(binding('color')).toEqual('red'); |
| 340 | + expect(binding('color')).toEqual('"red"'); |
334 | 341 | });
|
335 | 342 | </doc:scenario>
|
336 | 343 | </doc:example>
|
@@ -1188,7 +1195,10 @@ var ngModelDirective = function() {
|
1188 | 1195 | * @name ng.directive:ngChange
|
1189 | 1196 | *
|
1190 | 1197 | * @description
|
1191 |
| - * Evaluate given expression when user changes the input. |
| 1198 | + * Evaluate the given expression when the user changes the input. |
| 1199 | + * The expression is evaluated immediately, unlike the JavaScript onchange event |
| 1200 | + * which only triggers at the end of a change (usually, when the user leaves the |
| 1201 | + * form element or presses the return key). |
1192 | 1202 | * The expression is not evaluated when the value change is coming from the model.
|
1193 | 1203 | *
|
1194 | 1204 | * Note, this directive requires `ngModel` to be present.
|
|
0 commit comments