Apply pipe to input box

3.7k Views Asked by At

I have written thousandsSeparatorPipe and it is working fine with the label as shown below.

  <ion-label fixed>{{project.contingency | thousandsSeparatorPipe}}</ion-label>

But how can I apply that pipe to the ion-input? Because I need to show the thousands separator when user types on the below numeric box.Any help, please?

<ion-input type="number" formControlName="budget" [(ngModel)]="project.budget" ></ion-input>
1

There are 1 best solutions below

11
On BEST ANSWER

No, It's not possible to use pipes over inputs like above, even in AngularJS which is not a recommended way too.

Inorder to use you need to apply the two-way data binding with two instructions. [ngModel]="project.budget| thousandsSeparatorPipe" (ngModelChange)="project.budget= $event"

DEMO

Alternatively you could use some of the mask libraries for input out there and create a directive.