udos86 / ng-dynamic-forms

Rapid form development library for Angular
ISC License
1.32k stars 369 forks source link

Support for Masks when using Angular Material #1150

Open thomastardy opened 3 years ago

thomastardy commented 3 years ago

I'm submitting a


[ ] Bug / Regression
[x] Feature Request / Proposal

I'm using


NG Dynamic Forms Version: `14.0.1`

[ ] Basic UI
[ ] Bootstrap UI  
[ ] Foundation UI
[ ] Ionic UI
[ ] Kendo UI
[x] Material  
[ ] NG Bootstrap
[ ] Prime NG

Description

We've started using NG Dynamic Forms version 6.0.7 in a form-heavy application of ours where we use Angular Material as well. This worked perfectly and help us save lots of from code. We have quite a lot of inputs where we make use of masks. In the process of updating the application we wanted to update NG Dynamic Forms to the latest version but have seen that masks are not supported anymore when Angular Material is used.

Is there a way to bring the support for mask back when used with Angular Material?

clementsanzID commented 3 years ago

Hi,

I have the same issue. After some research i found a workaround here https://github.com/angular/angular/issues/16755#issuecomment-353063434 I didn't figure out how to add a tag in the model to use @ViewChild(tag) so i use document element :

constructor( ...
    @Inject(DOCUMENT) document ) {
}

public ngAfterViewInit() {
    const date =  document.getElementById( 'date' );
    const mask = [/\d/, /\d/, '/', /\d/, /\d/, '/', /\d/, /\d/, /\d/, /\d/];
    textMask.maskInput( {
      inputElement: date,
      mask: mask
    } );
}

Hope it's help