Angular 4 Input Mask
First, install it.
npm i @saritasa/ngx-text-mask --save
Then, import it into your
Then, use it in your component:
As you can see in the code above, you are passing an object to the
📍 For more information about the values that the
textMask object accepts, see
Unmasking the value that is stored in the model
Text Mask does not provide an option to unmask the model before storing it. You can sanitize the model on your side. See here for details.
change doesn't work
change on an input field will not work if
[text-mask] is present. You can use
(ngModelChange) instead. For more
information, see this page.
To see an example of the code running, follow these steps:
- Clone the repo,
git clone email@example.com:text-mask/text-mask.git
- Open http://localhost:3000
The code of the example is in
Unfortunately, we are unable to support Ionic 2
ion-input at this point as it overrides the
ControlValueAccessor that Text Mask requires to perform its job.