Pushing Iterated Rows Depending on Number Selected in Reactive Forms in Angular

扶醉桌前 提交于 2019-12-13 15:46:16

问题


I've a problem in iterating rows when i selecting a number in my dropdown. How would i push that number so that rows(cards) would be iterated depending on that number. My process is this, first you have to select Solo Traveller as 'No' so that the adults and children dropdowns would appear. That dropdown is my problem, how would i iterate rows(cards) depending on that number selected? I've made the rows(cards) but i don't know how would i iterate it. here's my stackblitz link

CLICK THIS LINK

 updateCountAdult(value) {
    console.log(value.target.value);
    this.form.addControl('adultRows', this.adultRows);
  }

  updateCountChildren(value) {
    console.log(value.target.value);
    this.form.addControl('childrenRows', this.childrenRows);
  }

  addAdult(): FormGroup {
    return this.fb.group({
      firstName: [null, Validators.required],
      lastName: [null, Validators.required]
    });
  }


  addChild(): FormGroup {
    return this.fb.group({
      firstName: [null, Validators.required],
      lastName: [null, Validators.required]
    });

}


回答1:


here is the edited stackblitz :

https://stackblitz.com/edit/iterated-according-to-selected-number-dkrxeh?file=app/app.component.html



来源:https://stackoverflow.com/questions/52315415/pushing-iterated-rows-depending-on-number-selected-in-reactive-forms-in-angular

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!