How to POST 3 FORM in 1 BUTTON Angular

Viewed 106

I have a button that can submit my Dynamic Form 2ARRAY but how to get the response of id ID to each other and pass it?

 this.fg = this.fb.group({
      name: [],
      lastname: [],
      Info: this.fb.array([this.item()]),
      setItem: this.fb.array([this.CreatesetItem('')]),
    });
  }

  ngOnInit() {
    this.item();
  }
  CreatesetItem(data): FormGroup {
    return this.fb.group({
      itemID:[0],
      ListItem: [data],
    });
  }
  item(): FormGroup {
    return this.fb.group({
      id:[],
      qty: [],
      name: [''],
    });
  }
  get setItem(): FormArray {
    return this.fg.get('setItem') as FormArray;
  }
  get Info(): FormArray {
    return this.fg.get('Info') as FormArray;
  }

How do you get the response of POST1 ID to the TESTING itemID? i can pass the id of the two but when it comes to the TESTING it wont pass the reposne of POST1 anyone can help me?

saveButton(){
console.log(this.fg.value)
    this.microSvc.Post(this.fg.value)
    .subscribe((respo)=>{
      this.headerID = respo.id;
      for (const item of this.fg.value?.Info){
        item.id = this.headerID;
         this.microSvc.Post1(item)
         .subscribe((response)=>{
        for(const serial this.fg.value?.SetItem){
          item.ItemId = this.detailsID
          this.microSvc.testing(serial).subscribe((res) =>{
            })
         }
         }) 
         })
         } 
       })
  }
0 Answers
Related