1
votes

When the property "name" is not present, the value indicated in "value" is displayed correctly. But when I add the property "name" needed to work with [(ngModel)] the property "value" stops working.

When i don't use "name" property throw this error:

ERROR Error: If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions.

Example 1: <input [(ngModel)]="person.firstName" name="first">

Example 2: <input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">

Neither of the two examples works

1
can you elaborate on the stops working part please? what did you expect to happen and what actually happens? - Aprillion
is person a FormControl? - Faaiz Khan

1 Answers

0
votes

if you are using input inside a form it should look this way.

 <form [formGroup]="formName" >
 <input   name= "email" formControlName="email">
 </form>