最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Angular form array with Single Value Issue - Stack Overflow

programmeradmin1浏览0评论

**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? *

***appponet.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>



***appponent.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;
  }

  
发布评论

评论列表(0)

  1. 暂无评论