1

I was trying to setValue , push values into FormArrays at the time of creation but its not working. Could someone tell me how to set values while creating FormArray ?

   public initCarriers() {
            return this._FB.group({
                Name: ['MGR', Validators.required],
                Age: ['42', Validators.required],
                Role: ['Actor', Validators.required]
            });
   }

  public loopEdit(){
    const control = < FormArray > this.carriersForm.get('CarriersArray');
    let arr = [1 , 2];
    for(let a of arr) {
        control.push(this.initCarriers());
    }
}

What i was trying to do in this code is, adding formarray two times with value of MGR, 42, Actor. but its not working values not assigning. Could someone please help me or tell me how to set values while creating FormArray ?

Andrew Adam
  • 1,572
  • 9
  • 22
Munna
  • 207
  • 1
  • 3
  • 7

0 Answers0