Typescript 使用Ngx intl tel输入模块保存电话号码后显示正确的国旗[7]

Typescript 使用Ngx intl tel输入模块保存电话号码后显示正确的国旗[7],typescript,angular7,Typescript,Angular7,我使用的是ngx intl tel输入版本2.2.0[与Angular 7兼容]。我有一个页面,其中包含一个人的所有详细信息[例如,名字、姓氏、出生日期、地址、国家、电话等]。因此,当我将电话号码与国家代码一起保存时,它被成功保存。但是,在同一页面上重新加载时,国旗不会根据保存的电话显示。我想根据国家代码显示正确的国旗,同时保存电话号码。 例如,我在代码中将defaultcountry设置为'CountryISO.Switzerland'。然后我选择另一个国旗,如“法国”,并保存一个电话号码[例

我使用的是ngx intl tel输入版本2.2.0[与Angular 7兼容]。我有一个页面,其中包含一个人的所有详细信息[例如,名字、姓氏、出生日期、地址、国家、电话等]。因此,当我将电话号码与国家代码一起保存时,它被成功保存。但是,在同一页面上重新加载时,国旗不会根据保存的电话显示。我想根据国家代码显示正确的国旗,同时保存电话号码。

例如,我在代码中将defaultcountry设置为'CountryISO.Switzerland'。然后我选择另一个国旗,如“法国”,并保存一个电话号码[例如,+33123456789]。在页面刷新中,电话保持不变,但国旗变成了瑞士而不是法国。请告知如何解决此问题。我的代码如下:
在HTML组件中,

<ngx-intl-tel-input class="custom-intl-tel-input" [cssClass]="'custom'" [preferredCountries]="preferredCountries" [enableAutoCountrySelect]="false" [enablePlaceholder]="true" [searchCountryFlag]="true" [searchCountryField]="['iso2', 'name']" [selectFirstCountry]="false" [selectedCountryISO]="defaultCountry" [maxLength]="15" [tooltipField]="'name'" [phoneValidation]="true" name="phoneC" id="phoneC" (ngModelChange)="onChangeTelephone($event)" [ngModelOptions]="{updateOn: 'blur'}" [(ngModel)]="contact.telephone" #phoneC="ngModel"> </ngx-intl-tel-input> 
this.preferredCountries = [CountryISO.Mexico]; this.defaultCountry = [CountryISO.Switzerland]; onChangeTelephone(event) { // save international number +33123456789 }


非常感谢

我发回了3个参数:countryCode、countryISO(toLowerCase())、phoneNumber。当我从后面得到这个参数时,我的国家现在是国旗了

//it's number from back
public phoneNumber: any;
//it's for ex 'af' 
public selectedCountryISO: any;

phoneNumber: new FormControl(this.phoneNumber, [
  Validators.required
]),

contact.phoneNumber = data.value.phoneNumber.number;
contact.countryCode = data.value.phoneNumber.dialCode;
contact.countryISO = data.value.phoneNumber.countryCode.toLowerCase();

html


我返回3个参数:countryCode、countryISO(toLowerCase())、phoneNumber。当我从后面得到这个参数时,我的国家现在是国旗了

//it's number from back
public phoneNumber: any;
//it's for ex 'af' 
public selectedCountryISO: any;

phoneNumber: new FormControl(this.phoneNumber, [
  Validators.required
]),

contact.phoneNumber = data.value.phoneNumber.number;
contact.countryCode = data.value.phoneNumber.dialCode;
contact.countryISO = data.value.phoneNumber.countryCode.toLowerCase();

html