Set a dynamic property in ngModel inside ngFor, with Angular 2+

0
1004

The answer was easy :

[(ngModel)]="selectedData[myField.name]"

If field.Name has a value of ‘label’, the previous code is equivalent as :

[(ngModel)]="selectedData.label"

LEAVE A REPLY

Please enter your comment!
Please enter your name here