Ngx-mask: i'm use ngxMark with formControlName is error

Created on 22 Oct 2018  路  6Comments  路  Source: JsDaddy/ngx-mask

<input formControlName="totalPaymentMethod" mask="00*.00" [(ngModel)]="numberOrStringFormModel" >

question

All 6 comments

@KanKai Hi. Could you provide error message ?

Bad practice using ngModel with formControlName

It's happening to me to:

<input type="text" formControlName="cpf" id="cpfInput" mask="000.000.000-00" matInput>

When I use formControl it works, but when I use formControlName (a form control inside a form group) it throws an error:

ngx-mask inputValue.slice is not a function

Please help me. I really like this lib because it's possible to get the 'unmasked' value.

Updating: The mask works, even though it throws an error after the page is loaded.

First I thought it was because of the matInput but it wasn't. Then I found the cause:

When the value is defined as an object the error occurs:
cpf: [{ value: ''}, [Validators.required]],

screenshot from 2018-11-30 09-46-16

But if its a simple value it doesn't cpf: ['', [Validators.required]],
cpf: ['', [Validators.required]],
screenshot from 2018-11-30 09-48-35

@kosmicke can you provide more details about you config and about your form, i did not find this problem

@kosmicke Did you solved your issue? I have this same error with a input with 4 mask possibilities, and I'm trying to change the mask after the function loads the data and write inside the input.

Was this page helpful?
0 / 5 - 0 ratings