P Rane
P Rane

Reputation: 306

Data bind to Array Angular 6

I have list of Array in a table , I want to bind input value with list of array Id separately to the array here my html <tr *ngFor="let entressEmployee of EntressForEmployee; let e = index "> <td style="text-align:left">{{entressEmployee.Description}}</td> <td> <input type="number" class="form-control" placeholder="Value"> </td></tr> and my EntressForEmployee Array look like this Incomming Array I want to bind ID with my input value.

Upvotes: 0

Views: 1915

Answers (3)

Rahul
Rahul

Reputation: 2128

Use your input of type='text' and then bind using [(ngModel)] like this

 <tr *ngFor="let entressEmployee of EntressForEmployee; let e = index ">
           <td style="text-align:left">{{entressEmployee.Description}}</td>
           <td> <input type="text"  class="form-control" placeholder="Value" [(ngModel)]='entressEmployee.ID'> 
</td>

Finally don't forget to import FormsModule in your AppModule - Happy coding !!

Upvotes: 1

Sachila Ranawaka
Sachila Ranawaka

Reputation: 41377

simply use ngModel

<td> <input type="number" [(ngModel)]="entressEmployee.ID" class="form-control" placeholder="Value">

Upvotes: 1

tausif
tausif

Reputation: 151

you can use property binding

<td> <input type="number" value={{entressEmployee.ID}} class="form-control" placeholder="Value">

Upvotes: 1

Related Questions