Angular 2 Form “Cannot Find Control”

前端 未结 2 1603
走了就别回头了
走了就别回头了 2021-01-14 04:54

I am trying to use Angular 2 Forms for validation, but when I try to add more than one control. It seems like it just gets ignored. I have followed many different guides to

2条回答
  •  再見小時候
    2021-01-14 05:09

    This may not be the answer to the original question, but this may be useful if you jumped here from google.

    You need to check these things.

    1. You must have a "name" attribute for all the controls which has [ngModel]

    2. If you exclude some fields from validation, then add [ngModelOptions]="{standalone: true}" (remember the first rule, still you need a "name")

    3. Make sure you have formControlName attribute for the controls that you are going to validate. (remember the first rule)

提交回复
热议问题