简体   繁体   中英

Angular binding to form not show all binded values with ngModel

I am writing an angular page which is binding a object with alot of fields to a form with many input text field. It is strange but only the first two fields are binding with values while the rest of the fields are empty. I swap the 2nd and 3rd input fields and the 3rd input field value shows up in the 2nd row spot. The 2nd input field which has been moved to the third row is blank. I looked at the HTML code but I am not sure why? I am learning angular and not sure why not all the input fields should show values. I only show 3 input fields but in my code I have more than 10 input rows but only the first 2 are showing the binded values. Any help is appreciated.

Update: I figured it out. With refreshed eyes, I noticed the error In my HTML, I was setting dual binding and all my #name="ngModel". I had this for all my input fields. The #name needed to be unique.

Update: I figured it out. With refreshed eyes, I noticed the error

In my HTML, I was setting dual binding and all my #name="ngModel". I had this for all my input fields. The #name needed to be unique.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM