Skip to content Skip to sidebar Skip to footer

Very Simple Usage Of Ngmodel

I have this very simple table body that generates a table based on the activityDays and for each clientType creates columns with some inputs. It works well. My problem now is how

Solution 1:

You could do something like this:

Component.ts:

exportclassComponent  {
  clientTypes = ['','','',''];
  clientTypesInputs = [];
}

Component.html:

<table><tr><td *ngFor="let clientType of clientTypes; let in=index"><div><inputvalue="0"type="number"min="0"required [(ngModel)]="clientTypesInputs[in]"  /></div></td></tr></table><ul><li *ngFor="let clientTypeInput of clientTypesInputs">{{clientTypeInput}}</li></ul>

clientTypesInputs is going to have the inputs at the index that they need to be acording to clientTypes array position.

Here is a working example:

https://stackblitz.com/edit/angular-artq8x

Post a Comment for "Very Simple Usage Of Ngmodel"