【问题标题】:Can't map Model values to formcontrols无法将模型值映射到表单控件
【发布时间】:2019-11-22 05:31:14
【问题描述】:

当我在编辑值期间尝试使用模型类将来自服务器的响应映射到 Angular 6 中的表单控件时,表单控件会等待事件来设置值。即使模型中有响应,为什么我不能使用模型设置表单控件值?我该如何解决这个问题

this.patientRegistrationService.getdata(data).subscribe(result=>
       {
        this.pmaster=result.pmaster;
        //pmaster is a model class
       }

【问题讨论】:

  • its not mapping 什么意思?
  • 编辑期间无法将响应中的值映射到表单控件
  • 请花点时间阅读How to Ask 并花更多精力正确解释您的问题

标签: javascript angular typescript


【解决方案1】:

也许有帮助:

如果您有一个名为 myForm 的表单组和一个名为 country 的表单控件:

this.patientRegistrationService.getdata(data).subscribe(result=>
{ 
        this.myForm.get('country').setValue(result.curCountry);
}

【讨论】:

    猜你喜欢
    • 2011-07-03
    • 1970-01-01
    • 2012-03-27
    • 1970-01-01
    • 1970-01-01
    • 2019-11-25
    • 2012-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多