【问题标题】:how to bind data to the formcontrolname in angular?如何以角度将数据绑定到formcontrolname?
【发布时间】:2019-12-16 08:51:24
【问题描述】:

这是我的表单中的示例表单项,供用户在创建新数据时输入:

<nz-form-item>
    <nz-form-label>{{ 'label.bank.number' | translate }}</nz-form-label>
    <nz-form-control [nzErrorTip]="'error.bank.number' | translate">
      <input nz-input formControlName="bankAccNo"/>
    </nz-form-control>
  </nz-form-item>

这是示例硬代码数据:

this.bank.push(
  {
  id: '0',
  code: 'P0001',
  bankName: 'MayBank',
  bankNumber: '1231231233',
  currency: 'RM',
  status: 'Active'
},
{
  id: '1',
  code: 'P0002',
  bankName: 'Public Bank',
  bankNumber: '1231123145',
  currency: 'RM',
  status: 'Inactive'
});

我试图实现的是当用户按下编辑按钮时,带有 formControlName="bankAccNo" 的输入框将检索银行号码数据。如果您对如何执行此操作有任何想法,请提供帮助,尝试了一些解决方案,但没有一个有效。

【问题讨论】:

    标签: ng-zorro-antd


    【解决方案1】:

    找到这个问题的解决方案:https://angular.io/api/forms/FormControlName

    【讨论】:

      猜你喜欢
      • 2019-06-12
      • 2020-01-03
      • 2019-03-30
      • 2021-10-04
      • 2019-07-25
      • 1970-01-01
      • 2019-03-31
      • 2021-12-06
      • 2018-02-24
      相关资源
      最近更新 更多