Add ability to use MaskPipe/MaskService inside component
Currently, there is no ability to inject MaskPipe/MaskService into component constructor to apply mask in TypeScript.
@nazar-kuzo We released new version with that property, try 6.2.8.
@Alexandr98, so I have installed the 6.2.8 version and here what I have:
ngx-mask.d.ts (file)

Seems like default d.ts generator renamed exports.
Also, MaskPipe has a dependency on MaskApplierService, so it makes things complicated where they supposed to be simple:
Example 1: I would like to apply mask inside my component
Solution 1:
- Inject MaskApplierService into component constructor
- create instance of MaskPipe and pass instance of MaskApplierService into constructor parameter
- use MaskPipe.transform method
Solution 2:
- Register MaskPipe as provider in my module like: { provide: MaskPipe, useClass: MaskPipe }
- Inject MaskPipe into component constructor
- use MaskPipe.transform method
Proposed Solution Can we make MaskPipe constructor parameterless, so we can use it as pure pipe? If MaskApplierService is used just as way to avoid code duplication, it could be used as internal class without need to be exported and registered as Angular Injectable.
This will allow create instances of MaskPipe without and additional steps provided and it will behave as pure stateless function.
Is this possible already? to use in component?
@lixaotec It is 😊
Thanks dude. Just managed to it. Passed maskpipe in a constructor . Worked very well, im building a generic pipe for my datatable
@lixaotec Is there an example you could provide with the parameters you passed to the maskPipe please? Thanks a lot
ngx-mask works with Angular, and Angular - Ionic!
constructor(private _formBuilder: FormBuilder, private maskPipe: MaskPipe) {}
updateWithMask(event) { this.myForm.controls.cpf.setValue(this.maskPipe.transform(event.currentTarget.value, '000.000.000-00')); }
Ionic CLI : 6.19.1 Ionic Framework : @ionic/angular 6.1.8 @angular-devkit/build-angular : 13.2.6 @angular-devkit/schematics : 13.2.6 @angular/cli : 13.2.6 @ionic/angular-toolkit : 6.1.0
Reference: http://dev.diogomachado.com/ionic-input-with-mask/