1

I'm trying ti bind the formControl value on a input element dynamically in a loop.

<div *ngFor="let value of values"> <input attr.formControl="{{value}}" type="text"/> </div> 

This isn't working. The formControl attribute isn't a standart html attribute so I guess there has to be some other way to bind the value.

Usually the formControll is bound like this

[formControl]="name" 

1 Answer 1

1

This should do the trick:

<div *ngFor="let value of values"> <input [formControlName]="value" type="text"/> </div> 
Sign up to request clarification or add additional context in comments.

2 Comments

No, it's not working. Error: Cannot find control with name: 'value'. Btw, did u give the postfix name behid formControl on purpose or it's just a typo ?
@user49126 My bad, I edited the comment, check it now. formControlName is not a typo, you can check how to create model-driven forms on these links: coryrylan.com/blog/… and blog.thoughtram.io/angular/2016/06/22/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.