If ngModel is used within a form tag set name or set standalone error

I have found where the error is. I have put it here to help someone that has the same error and the same knowledge about Angular (or programming).

The error is in the following select, it hasn't a name. I did this to fix it:

<select name="ProductId-{{rowIndex}}" #productId="ngModel" [(ngModel)]="productionorder.productid" required>
    <option></option>
    <option *ngFor="let product of products" [value]="law.lawId">{{law.name}}</option>
</select>

Error: If ngModel is used within a form tag set name or set standalone error

Simple Soultions:

Add name attribute to input field in case of ngform or ngsubmit you are using

Example 1: <input [(ngModel)]="User.age" name="age">



or 

**if you are using direct [(ngModel)]="User.age" ,,,then add this [ngModelOptions]="{standalone: true}" to input field**

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

Tags:

Angular