PeterStaev / nativescript-masked-text-field

:hash: A NativeScript Masked Text Field widget
Apache License 2.0
25 stars 24 forks source link

TypeError: this.mask.split is not a function #8

Open romulowspp opened 7 years ago

romulowspp commented 7 years ago

I'm using the version for the angular. I followed all the steps that have been described here.

But when my page loads I get the following error:

JS: TypeError: this.mask.split is not a function
JS:     at MaskedTextFieldBase._generateMaskTokens (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/nativescript-masked-text-field/masked-text-field-common.js:48:35)
JS:     at valueChanged (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/nativescript-masked-text-field/masked-text-field-common.js:131:16)
JS:     at MaskedTextField.Property.set [as mask] (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/tns-core-modules/ui/core/properties/properties.js:82:25)
JS:     at ViewUtil.setPropertyInternal (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/nativescript-angular/view-util.js:192:32)
JS:     at ViewUtil.setProperty (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/nativescript-angular/view-util.js:155:18)
JS:     at EmulatedRenderer.NativeScriptRenderer.setAttribute (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/nativescript-angular/renderer.js:126:30)
JS:     at DebugRenderer2.setAttribute (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/@angular/core/bundles/core.umd.js:13383:23)
JS:     at createElement (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/@angular/core/bundles/core.umd.js:9378:22)
JS:     at createViewNodes (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/@angular/core/bundles/core.umd.js:12051:44)
JS:     at callViewAction (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/@angular/core/bundles/core.umd.js:12537:13)
JS:     at execComponentViewsAction (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/@angular/core/bundles/core.umd.js:12446:13)
JS:     at createViewNodes (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/@angular/core/bundles/core.umd.js:12120:5)
JS:     at createRootView (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/@angular/core/bundles/core.umd.js:11998:5)
JS:     at callWithDebugContext (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/@angular/core/bundles/core.umd.js:13213:42)
JS:     at Object.debugCreateRootView [as createRootView] (file:///data/data/org.nativescript.meupatrocinio/files/app/tns_modules/@angular/core/bundles/core.umd.js:12673:12)

The html: <MaskedTextField col="2" class="text-field text-field-bordered" mask="000" keyboardType="number"></MaskedTextField>

Thanks.

PeterStaev commented 7 years ago

Hey @Ablankzin , this seems to be an issue with the NS Angular implementation specific to the format of the mast and that it is automatically converted by the runtime to a number. So in the plugin I receive the value as the number 0 and not as the string 000. I've logged an issue: https://github.com/NativeScript/nativescript-angular/issues/854 so we will see what will happen.

Sadly currently I do not have a workaround for this, except to change your mask to have at least one non-digit character, so that it does not get converted by the runtime...

romulowspp commented 7 years ago

I made a little change to temporarily support mask 9.

9

vcooley commented 7 years ago

I've run into this before and temporarily solved this issue by inserting a zero-width space between two of the zeros.