From 6e55b890de282ed5ad8984b9494eea2b3e4929c5 Mon Sep 17 00:00:00 2001 From: George Kalpakas Date: Tue, 6 Mar 2018 15:31:27 +0200 Subject: [PATCH] docs(input[radio]): explain what happens with same name on multiple inputs Closes #15009 Closes #16478 --- src/ng/directive/input.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 3b841d25a348..5d9bf66fa468 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -980,6 +980,33 @@ var inputType = { * @description * HTML radio button. * + * **Note:**
+ * All inputs controlled by {@link ngModel ngModel} (including those of type `radio`) will use the + * value of their `name` attribute to determine the property under which their + * {@link ngModel.NgModelController NgModelController} will be published on the parent + * {@link form.FormController FormController}. Thus, if you use the same `name` for multiple + * inputs of a form (e.g. a group of radio inputs), only _one_ `NgModelController` will be + * published on the parent `FormController` under that name. The rest of the controllers will + * continue to work as expected, but you won't be able to access them as properties on the parent + * `FormController`. + * + *
+ *

+ * In plain HTML forms, the `name` attribute is used to identify groups of radio inputs, so + * that the browser can manage their state (checked/unchecked) based on the state of other + * inputs in the same group. + *

+ *

+ * In AngularJS forms, this is not necessary. The input's state will be updated based on the + * value of the underlying model data. + *

+ *
+ * + *
+ * If you omit the `name` attribute on a radio input, `ngModel` will automatically assign it a + * unique name. + *
+ * * @param {string} ngModel Assignable AngularJS expression to data-bind to. * @param {string} value The value to which the `ngModel` expression should be set when selected. * Note that `value` only supports `string` values, i.e. the scope model needs to be a string,