【问题标题】:How to set Initial value on ngx-mat-intl-tel-input (NgxMatIntlTelInput - International Telephone Input for Angular Material)如何在 ngx-mat-intl-tel-input 上设置初始值(NgxMatIntl​​TelInput - Angular Material 的国际电话输入)
【发布时间】:2021-01-22 09:31:28
【问题描述】:

如何设置物料表单域的初始值ngx-mat-intl-tel-input 以角度形式加载?例如,我展示了一个可编辑的表单,可以进行任何修改,并且应该将现有值加载到此电话号码字段中。

我尝试了以下方法,但最终在控制台中抛出错误。找不到名称为“电话”的控件

ngOnInit()
{
this.profileForm.controls['phone'].setValue(                '+91' + '123455555');
}
<mat-form-field class="" floatLabel="auto">
  <mat-label>Phone number</mat-label>
  <ngx-mat-intl-tel-input formControlName="phone"           [enablePlaceholder]="true" [enableSearch]="true"
[preferredCountries]="['in']" name="phone" #phone>
  </ngx-mat-intl-tel-input>
</mat-form-field>

请告诉我如何点击它。

谢谢 萨拉姆

【问题讨论】:

    标签: javascript angular angular-material frontend


    【解决方案1】:

    this.profileForm.controls.phone.patchValue('+91123455555');

    this.FORMNAME.controls.FIELDNAME.patchValue('+91123455555');

    【讨论】:

      猜你喜欢
      • 2019-08-22
      • 2020-01-05
      • 1970-01-01
      • 2020-03-15
      • 1970-01-01
      • 2019-09-26
      • 2014-09-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多