Text-mask: Problem with Angular2 and Ionic2 when using Reactive Forms

Created on 22 Feb 2017  路  4Comments  路  Source: text-mask/text-mask

Hey there,

Just tried to set this up and quickly ran into the following error. Not sure what I'm doing wrong but any help would be appreciated. Thanks! Using your recent Angular 5.0.0 release.

Uncaught TypeError: Cannot read property 'subscribe' of null
    at http://localhost:8100/build/main.js:102229:14
    at new t (http://localhost:8100/build/polyfills.js:3:11329)
    at toPromise (http://localhost:8100/build/main.js:102227:12)
    at _convertToPromise (http://localhost:8100/build/main.js:10800:187)
    at Array.map (native)
    at http://localhost:8100/build/main.js:10793:80
    at http://localhost:8100/build/main.js:10806:49
    at Array.map (native)
    at _executeAsyncValidators (http://localhost:8100/build/main.js:10806:23)
    at FormControl.asyncValidator (http://localhost:8100/build/main.js:10793:28)

And my stuff:

        this.emailForm = this.fb.group({
            email: [this.auth.getUser().local.email, [Validators.required, CustomValidators.email]]
        });
    phoneNum = '';
    mask: any = {
        mask: ['(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/],
        placeholderChar: ' ',
        guide: false
    };

I tried with and without [(ngModel)]:

        <ion-item>
          <ion-label floating>Telephone number</ion-label>
          <ion-input [textMask]="mask" formControlName="phone" type="phone" placeholder=""></ion-input>
        </ion-item>

Thoughts? Thanks. I also tried without . No luck.

Most helpful comment

what's the solution for you?

All 4 comments

Errr. I might be an idiot. Hang on.

Yup. Thanks :)

what's the solution for you?

[textMask]="mask" -> [textMask]="{mask: mask}"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

badre429 picture badre429  路  3Comments

cargonsan picture cargonsan  路  4Comments

kenpeter picture kenpeter  路  3Comments

Sn3b picture Sn3b  路  6Comments

AliveDD picture AliveDD  路  5Comments