question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose a service for applying mask in typescript

See original GitHub issue

Please advise how to apply a mask in typescript code.

Correct me if I am wrong, but I do not see any exposed service that I can use to do this. MaskService cannot be injected into a service, because it requires an ElementRef, which throws an error on injection NullInjectorError: No provider for ElementRef!.

There is another service MaskApplierService, but it is not exposed in the public_api. In any case there is no documentation on the difference between these two services.

If it is not currently possible to apply the mask outside of an Angular template, please add as a feature the correct service to use, or a utility class that can be imported. The use case is for data export.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
ValeriaKochegarovacommented, May 7, 2019

@kevinrstone @douggass we fixed this , you can use in mask 7.9.8 version For using you should use MaskApplierService Example:

constructor(private maskService: MaskApplierService) {} 
  exportData() {
    const phoneNumber: string = this.maskService.applyMask('12345678901', '000-0000-00-00');
}
1reaction
douggasscommented, May 8, 2019

@kevinrstone @douggass we fixed this , you can use in mask 7.9.8 version For using you should use MaskApplierService Example:

constructor(private maskService: MaskApplierService) {} 
  exportData() {
    const phoneNumber: string = this.maskService.applyMask('12345678901', '000-0000-00-00');
}

work when I import ‘ea’: import { ɵa } from ‘ngx-mask’; … constructor(private maskApplierService: ɵa) {
console.log(maskApplierService.applyMask(‘5555’, ‘00-00’)); } …

thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use Input Masks to Validate Input in an Angular App
Input validation is always a chore to set up. An input mask is a way to enforce the format of the user's input...
Read more >
How to apply mask to a default value in Typescript
I have a mask-phone directive that works perfectly in the input when the user write a value, but I need to set a...
Read more >
Google TypeScript Style Guide
This guide is based on the internal Google TypeScript style guide, ... Note: If you're creating an alias just to expose it to...
Read more >
tslog - Extensible TypeScript Logger for Node.js and Browser ...
Extensible TypeScript Logger for Node.js and Browser: Dependency free, Fully customizable, Pretty errors, stack traces, and JSON output to attachable ...
Read more >
ngx-mask - npm
Import ngx-mask directive, pipe and provide NgxMask providers with provideNgxMask function. With default config options application level. bootstrapApplication( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found