Angular form array with Single Value Issue

Discussão em 'Angular' iniciado por Tim, Fevereiro 10, 2025.

  1. Tim

    Tim Guest

    **The for the react dynamic question, only the label is displayed (not the text box). There is a mismatch between the .ts and html. What should the constructor contact? *

    ***app.componet.html:***

    <div class="form-group col-md-9">
    <label for="name">LOB Contact(s)</label>
    <div formArrayName="contact_emails">
    <div *ngFor="let contact of contact_emails.controls; let i=index; ">
    <textarea formControlName="i" style="width:90%;">
    </textarea>
    <button type="button" class="btn btn-primary btn-xs"
    (click)="addContact_Emails()">
    <span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
    </button>
    <button type="button" *ngIf="i>0" class="btn btn-danger btn-xs"
    (click)="removeContact_Emails(i)">
    <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
    </button>
    </div>
    </div>
    </div>



    ***app.component.ts:***

    constructor(private fb: FormBuilder) {
    this.appForm = this.fb.group({
    contact_emails: this.fb.array([]),
    });
    }


    get contact_emails() {
    return this.appForm.get('contact_emails') as FormArray;
    }

    Continue reading...

Compartilhe esta Página