![](/img/trans.png)
[英]Unable to clear the ngx-mat-intl-tel-input after form submit in angular 10
[英]How to set Initial value on ngx-mat-intl-tel-input (NgxMatIntlTelInput - International Telephone Input for Angular Material)
如何在加载 angular 表单中的材质表单字段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>
请让我知道如何点击它。
谢谢萨拉姆
this.profileForm.controls.phone.patchValue('+91123455555');
this.FORMNAME.controls.FIELDNAME.patchValue('+91123455555');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.