diff options
| author | Abdessamad Idrissi | 2014-01-07 00:47:41 +0100 |
|---|---|---|
| committer | Caitlin Potter | 2014-01-17 18:15:25 -0500 |
| commit | 8dd4f14a04afdf1cc1d1ab8448a0ec533799dfaf (patch) | |
| tree | 4f50aea8bf6607b095a15ca3a856be30b06c0580 /src/ng/directive | |
| parent | 7ba30fd2e748f1878c085d7f76a8c59215d4694b (diff) | |
| download | angular.js-8dd4f14a04afdf1cc1d1ab8448a0ec533799dfaf.tar.bz2 | |
docs(input): document ngValue directive
Extend the example with ng-value showing how to deal with default checked radio boxes.
Closes #5654
Diffstat (limited to 'src/ng/directive')
| -rw-r--r-- | src/ng/directive/input.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index fbcf3b32..706844eb 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -309,6 +309,8 @@ var inputType = { * @param {string=} name Property name of the form under which the control is published. * @param {string=} ngChange Angular expression to be executed when input changes due to user * interaction with the input element. + * @param {string} ngValue Angular expression which sets the value to which the expression should + * be set when selected. * * @example <doc:example> @@ -316,21 +318,26 @@ var inputType = { <script> function Ctrl($scope) { $scope.color = 'blue'; + $scope.specialValue = { + "id": "12345", + "value": "green" + }; } </script> <form name="myForm" ng-controller="Ctrl"> <input type="radio" ng-model="color" value="red"> Red <br/> - <input type="radio" ng-model="color" value="green"> Green <br/> + <input type="radio" ng-model="color" ng-value="specialValue"> Green <br/> <input type="radio" ng-model="color" value="blue"> Blue <br/> - <tt>color = {{color}}</tt><br/> + <tt>color = {{color | json}}</tt><br/> </form> + Note that `ng-value="specialValue"` sets radio item's value to be the value of `$scope.specialValue`. </doc:source> <doc:scenario> it('should change state', function() { - expect(binding('color')).toEqual('blue'); + expect(binding('color')).toEqual('"blue"'); input('color').select('red'); - expect(binding('color')).toEqual('red'); + expect(binding('color')).toEqual('"red"'); }); </doc:scenario> </doc:example> |
