Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 Input Custom Pipe

Is there any way to use currency or a custom pipe inside an input text in Angular 2?

I've tried this:

<input [(ngModel)]="order.price | currency"/>

But without success

like image 781
Kayo Lima Avatar asked Jun 16 '26 11:06

Kayo Lima


1 Answers

It's not possible to use pipes in inputs, even in angular 1.

What you are looking for is a mask directive. For angular1 there are a lot of directives like ngMask, angular-input-masks and others.

Angular2 is in release candidate right now (06/02/2016), so there are just a few "directives".

You can also build your own mask component.

like image 93
Gabriel Hobold Avatar answered Jun 19 '26 00:06

Gabriel Hobold



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!