Skip to content

Commit e12db36

Browse files
committed
docs(input[radio]): explain what happens with same name on multiple inputs
Closes angular#15009
1 parent 4f4ad3c commit e12db36

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/ng/directive/input.js

+25
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,31 @@ var inputType = {
980980
* @description
981981
* HTML radio button.
982982
*
983+
* **Note:**<br>
984+
* All inputs controlled by {@link ngModel ngModel} (including those of type `radio`) will use the
985+
* value of their `name` attribute to determine the property under which their
986+
* {@link ngModel.NgModelController NgModelController} will be published on the parent
987+
* {@link form.FormController FormController}. Therefore, you should avoid using the same `name`
988+
* for multiple inputs of a form, or else they will overwrite each other's `NgModelController` on
989+
* the parent `FormController`.
990+
*
991+
* <div class="alert alert-info">
992+
* <p>
993+
* In plain HTML forms, the `name` attribute is used to identify groups of radio inputs, so
994+
* that the browser can manage their state (checked/unchecked) based on the state of other
995+
* inputs in the same group.
996+
* </p>
997+
* <p>
998+
* In AngularJS forms, this is not necessary. The input's state will be updated based on the
999+
* value of the underlying model data.
1000+
* </p>
1001+
* </div>
1002+
*
1003+
* <div class="alert alert-success">
1004+
* If you omit the `name` attribute on a radio input, `ngModel` will automatically assign it a
1005+
* unique name.
1006+
* </div>
1007+
*
9831008
* @param {string} ngModel Assignable AngularJS expression to data-bind to.
9841009
* @param {string} value The value to which the `ngModel` expression should be set when selected.
9851010
* Note that `value` only supports `string` values, i.e. the scope model needs to be a string,

0 commit comments

Comments
 (0)