I have a mask-phone directive that works perfectly in the input when the user write a value, but I need to set a default value and I don't know how to apply the mask directive in the component method. The value is show it in the input without the mask and only if I modify that value the mask comes.
The problem I have is that in Germany has several possibilities for a telephone number, so I can not set a specific mask in the default value, for example: (49)(170)-1111111 (49)(1514)-1111111 (49)(25679)-1111111
I wrote an example, that you can see in the follow link: https://stackblitz.com/edit/angular5-phone-mask-directive-roeqfk?file=app/app.component.ts
Thanks in advance :)
You could provide the default value from inside the directive and set the mask in the
OnInitlifecycle hook. This would additionally have the benefit that the default value is the same each time you use this directive.Code: