카테고리 없음
[Angular 2+] [(ngModel)] must need "name" attribute
Juyeon Ji
2020. 10. 13. 18:55
Naming control elements
When you use [(ngModel)] on an element, you must define a name attribute for that element. Angular uses the assigned name to register the element with the NgForm directive attached to the parent <form> element.
The example added a name attribute to the <input> element and set it to "name", which makes sense for the hero's name. Any unique value will do, but using a descriptive name is helpful.
-
Add similar [(ngModel)] bindings and name attributes to Alter Ego and Hero Power.
-
You can now remove the diagnostic messages that show interpolated values.
-
To confirm that two-way data binding works for the entire hero model, add a new binding at the top to the component's diagnostic property.