I am using Ng2TelInput in my Angular 13 application and trying to bind the country code and phone number.
Html
<div class="col-12">
<div><label for="inputPhone" class="form-label">Phone</label></div>
<input type="number" class="custom-tel-input form-control" ng2TelInput [ng2TelInputOptions]="ng2TelInputOptions"
(countryChange)="onCountryChange($event)" formControlName="phone" ></div>
Ts
import { Ng2TelInput} from 'ng2-tel-input';
countryCode: string = "";
countryCodeName: string = '';
ng2TelInputOptions = {
initialCountry: this.countryCodeName
}
On form binding
this.ng2TelInputOptions = { ...this.ng2TelInputOptions, initialCountry: obj["country_code"] };
this.profileForm.setValue({
firstName: obj["first_name"],
lastName: obj["last_name"],
username: obj["username"],
email: obj["email"],
phone: obj["phone_number"],
countryCode: obj["country_code"],
})
The country code was not displaying on form load. Is there any way so that I can get the country iso2 value using this country code in 'Ng2TelInput'?
Along with that padding style also collapsed for phonenumber field when i change it to Ng2TelInput.
For fixing this I have added css as
:host ::ng-deep .iti {
width: 100%;
}
.iti--allow-dropdown {
width: 100% !important;
}
but both doesnt works as expected.
