I’m having an issue with an ion-input, which drops this error below when holding down the delete key.
"Error: Invalid argument '' for pipe 't'
at new Error (native)
at Error.v (file:///android_asset/www/build/polyfills.js:3:4864)
at e [as constructor] (file:///android_asset/www/build/main.js:94:11171)
at new e (file:///android_asset/www/build/main.js:14:10469)
at n (file:///android_asset/www/build/main.js:9:10302)
at t.transform (file:///android_asset/www/build/main.js:9:11000)
at file:///android_asset/www/build/main.js:1:17764
at e.detectChangesInternal (file:///android_asset/www/build/main.js:125:10032)
at e.t.detectChanges (file:///android_asset/www/build/main.js:4:8847)
at e.t.internalDetectChanges (file:///android_asset/www/build/main.js:4:8640)
at e.detectChangesInternal (file:///android_asset/www/build/main.js:120:27362)
at e.t.detectChanges (file:///android_asset/www/build/main.js:4:8847)
at t.detectChangesInNestedViews (file:///android_asset/www/build/main.js:4:28534)
at e.detectChangesInternal (file:///android_asset/www/build/main.js:80:24234)
at e.t.detectChanges (file:///android_asset/www/build/main.js:4:8847)", source:
file:///android_asset/www/build/main.js (29)
This one below is my ion-input:
<ion-input color="primary_light" [(ngModel)]="montco_ui" type="number
(keyup)="formataNumero()"></ion-input>
Also, I’m using this algorithm to handle 2 decimal places, which is working fine, since I guess the issue is related to the type number property on the ion-input.
formataNumero(separador: string = '.', decimais: number = 2) {
console.log('formataNumero called');
let a: any = this.montco_ui.split('');
let ns: string = '';
a.forEach((c: any) => { if (!isNaN(c)) ns = ns + c; });
ns = parseInt(ns).toString();
if (ns.length < (decimais + 1)) {
ns = ('0'.repeat(decimais + 1) + ns);
ns = ns.slice((decimais + 1) * -1);
}
let ans = ns.split('');
let r = '';
for (let i = 0; i < ans.length; i++)
if (i == ans.length - decimais) {
r = r + separador + ans[i]; else r = r + ans[i];
}
this.montco_ui = r;
}
Finally, this is the variable that keeps the value:
public montco_ui: string = "0.00";
P.S.: I'm using Ionic 2 for my project.