【问题标题】:Angular pipe with reactive formControlName of angular form array具有角形式数组的反应形式控制名称的角管道
【发布时间】:2022-02-06 23:11:09
【问题描述】:

这里我使用自定义管道来格式化费率字段。 这是只读字段。 问题是值属性未在页面加载时格式化速率字段。 哪个适用于其他领域

<div formArrayName="rateList" *ngFor="let product of formData.controls; let i=index;">
                    <div [formGroupName]="i">
                      <input formControlName="rate" readonly="readonly"
                        [value]="formData.controls[i].get('rate').value  | udpCurrency : false : this.translate.currentLang" />
                    </div>
                  </div>

【问题讨论】:

  • 你不需要使用 formControlName。记住一个 FormGroup(formArray 或 FormControl)独立存在于 .html 中的输入或不存在)。

标签: javascript html angular


【解决方案1】:

我不知道确切的答案,但作为一种解决方法,您可以在将值设置为表单数组时使用 setTimeout。

setTimeout(()=> {
  this.rateList.setValue(someRateArray)
} ,0)

【讨论】:

    猜你喜欢
    • 2017-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-31
    • 2020-09-02
    • 1970-01-01
    相关资源
    最近更新 更多