Multiple inputs with the same name bug #7647
Description
When you have multiple input fields with the same name, like radio buttons for example, you are getting one ngModel
controller for each input. But, when you addressing this field by name, like this: formName.fieldName
, you are getting a reference to the last ngModel
controller.
The problem is that this controllers doesn't know about each other and do not coordinate their state. And from the user perspective they must have a shared state.
>> The bug is illustrated here <<
In the provided example, I'm trying to detect pristine state of the gender radio field, but I'm getting incorrect result, since I'm getting pristine state not of the entire radio group but only of the last radio button in the group.
From the end-user perspective this can be considered a real bug.
As a solution to this problem, maybe we should use a single ngModel
controller for all inputs with the same name, or probably better, to synchronize the state of ngModel
s from the same group, so properties like $pristine
would be consistent.