angular: Forms should throw error if two or more NgModels appear in form with the same name

[ ] bug report => search github for a similar issue or PR before submitting [x] feature request [ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

Currently there is no error or warning if two form controls have the same name:

<input name="entireStateCoverage" type="checkbox" [(ngModel)]="item.entireStateCoverage">
<input name="entireStateCoverage" type="checkbox" [(ngModel)]="item.active">

Expected behavior

Forms should throw error if duplicate names are detected.

What is the motivation / use case for changing the behavior?

This leads to unpredictable results (value overwrites) which are difficult to find.

  • Angular version: 2.4.3

  • Browser: [all]

  • Language: [all]

About this issue

  • Original URL
  • State: open
  • Created 7 years ago
  • Reactions: 9
  • Comments: 17 (13 by maintainers)

Most upvoted comments

I’d like to work on this issue.

@phalgunv Are you still working this? If not I’d like to give it a shot. Thanks!

@phalgunv The angular project uses yarn instead of npm. So just install yarn with “sudo npm install --global yarn” and then install the packages with yarn “yarn install”. I would also like to contribute to this project, do you want to work on this issue together?