-
Notifications
You must be signed in to change notification settings - Fork 343
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete dial code #359
Comments
I think you should do the manipulation yourself. Meaning, remove the dial code manually. Unless you have a better proposal :) |
Any idea on how can that be done? |
If your phone numbers are saved in a consistent format using private removeDialCode(phoneNumber: string): string {
if (phoneNumber.startsWith('+')) {
phoneNumber = phoneNumber.substr(phoneNumber.indexOf(' ') + 1);
}
return phoneNumber;
} |
That would work if I had the following formar +1 415-629-7292; however I'm storing on my database +14156297292 without any space, in that case, do you know how to find the dial code? |
If you use a formControl I think this is the code you are looking for: this.formControl.valueChanges.subscribe((event: any) => {
} This code does the following: when formControl value gets set first, it will trigger this function. Then it checks if the current shown number includes a + (so includes dial code), if it does, we set the current value to the nationalNumber instead, which is the one without dial code. I hope this solves the problem. |
Hi all, so basically I can succesfully save to my backend the phone number with its dial code, which is used to send sms, however, once I get the phone number back from my server, it shows the flag and the number, I would like to only have the number without the dial code since showing the flag is enought
https://stackblitz.com/edit/ngx-intl-tel-input-demo-ng-10-fybvpx?file=src/app/app.component.ts
The text was updated successfully, but these errors were encountered: