根据在 Angular 的响应式表单中选择的数字推送迭代行 [英] Pushing Iterated Rows Depending on Number Selected in Reactive Forms in Angular

查看:19
本文介绍了根据在 Angular 的响应式表单中选择的数字推送迭代行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在下拉列表中选择一个数字时,我在迭代行时遇到了问题.我将如何推送该数字,以便根据该数字迭代行(卡片).我的流程是这样的,首先您必须将 Solo Traveler 选择为否",以便出现成人和儿童下拉菜单.该下拉列表是我的问题,我将如何根据所选数字迭代行(卡片)?我已经制作了行(卡片),但我不知道如何迭代它.这是我的 stackblitz 链接

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

点击此链接

 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]
    });

}

推荐答案

这里是编辑过的 stackblitz :

here is the edited stackblitz :

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

这篇关于根据在 Angular 的响应式表单中选择的数字推送迭代行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆