How to use dynamic key in ngModel? I am using the primeNg library and i'm trying to bind a dynamic key to the ngModel
this is the html template
<p-table [columns]="cols" [value]="data">
<ng-template pTemplate="body" let-rowData let-columns="columns">
<tr>
<td *ngFor="let col of columns">
<input type="text" pInputText [(ngModel)]="rowData[col.field]"/>
</td>
</tr>
</ng-template>
</p-table>
this is the "cols" variable
cols = [
{ field: 'variables.code', header: 'Code' },
{ field: 'variables.name', header: 'Name' },
];
and this is an example of data
[{
"variables": {
"code": "D44D5",
"name": "keyboard"
}
}]