You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a form where I'm using this component for taking user's phone number. But, when I use this form for updating existing user details this is not working. All other values are pre-filled for user to update. I'm using a full object to populate the value for phone number instead of just the E.164 format string.
The function to convert string to phone number object looks like this:
And I use this function to patch value to phoneNumber control
// ...if(this.user.phoneNumber){constphone=this.getIntlTelInputPhoneNumber(this.user.phoneNumber);// this is used for setting the dynamic country flag from phone numberthis.selectedCountry=phone.countryCode.toLowerCase()asCountryISO;this.userForm.get('phoneNumber')?.patchValue(phone);this.phoneNumberLoaded=true;// cd is ChangeDetectorRefthis.cd.detectChanges();}// ...
This shows the control filled with value
Now, when I just focus on the element and leave the input without modifying anything, I'm getting the error of invalid phone number.
The text was updated successfully, but these errors were encountered:
hirenchauhan2
changed the title
Changing the country on pre-filled input makes the control value to null
Blur event on pre-filled input makes the control invalid
Sep 28, 2022
Upon further checking, I found that the control was already invalid, not sure what was the reason? When I check the the control by inspecting it without focusing on it, I can see it has all values in the object of value for control. Still not sure why it is behaving like that. Any idea what could be wrong?
I have a form where I'm using this component for taking user's phone number. But, when I use this form for updating existing user details this is not working. All other values are pre-filled for user to update. I'm using a full object to populate the value for phone number instead of just the E.164 format string.
The function to convert string to phone number object looks like this:
And I use this function to patch value to phoneNumber control
This shows the control filled with value
Now, when I just focus on the element and leave the input without modifying anything, I'm getting the error of invalid phone number.
Env:
The text was updated successfully, but these errors were encountered: