Konstantin Kim
Konstantin Kim

Reputation: 239

Input inside form array is bugged

Stackblitz example

Why when I start typing into the input, it bugs and loses focus? Furthermore, I can't type more than 4 symbols. Can you help, please?

Upvotes: 0

Views: 67

Answers (1)

nash11
nash11

Reputation: 8650

You need to iterate over each form control instance provided by the aliases form array instance (Source: docs). You are iterating over the value of the credentials form control.

Try looping over form.get('credentials').controls instead

<div formArrayName="credentials" *ngFor="let creds of form.get('credentials').controls; let i = index">
  <ng-container [formGroupName]="i">
    <input placeholder="Username" formControlName="username">
    <input placeholder="Password" formControlName="password">
  </ng-container>
</div>

Upvotes: 1

Related Questions