Ion-input currency format

Sorry I have tried it but found no solution. Did something like this but haven’t found a valid convert algorithm yet. Also the changeDetection does not work properly with this solution. But maybe you can start from here:

<ion-content padding>
  {{myModelVariable}}
  <ion-input type="string" elastic placeholder='{{placeholder}}' [value]="myModelVariable" (keyup)="convert($event)"></ion-input>
</ion-content>
import { Component } from '@angular/core';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  placeholder = 'Please enter...'
  myModelVariable = '';

  convert(event: any) {
    console.log('old:', this.myModelVariable);
    this.myModelVariable = event.target.value.replace(/[^\d\.]/g ,'');
    console.log('new:', this.myModelVariable);
  }

}
1 Like