Angular 2: Accessing data from FormArray

前端 未结 4 1046
生来不讨喜
生来不讨喜 2021-01-31 16:23

I have prepared a from using ReactiveForms provided by angular2/forms. This form has a form array products:

this.checkoutFormGroup = this.fb.group({
                     


        
4条回答
  •  被撕碎了的回忆
    2021-01-31 16:52

    // in .ts component file //

    getName(i) {
        return this.getControls()[i].value.name;
      }
    
      getControls() {
        return (this.categoryForm.get('categories')).controls;
      }
    

    // in reactive form - Template file //

    
          
    
    
    

提交回复
热议问题