我在Angular 2材料应用程序中有一个表格,价格为:
<md-input [(ngModel)]="price" placeholder="Price"> </md-input>{{price|customCurrency}}
哪一个 uses a custom version of the CurrencyPipe 如本Plnkr所示:
CurrencyPipe
http://plnkr.co/edit/OM039CYEsS5CfhEuZdBN?p=preview
而是显示原始输入字段值:
Price 100 $1.00
我还想申请 customCurrency 管道直接连接到输入字段显示值,因此看起来像这样:
customCurrency
Price $1.00
当我键入100时,最好是在键入时将管道应用于显示值,但前提是只能这样做 模糊 这就足够了。你知道这怎么可能吗?
这在角度2中是不可能的;看见 Angular 2 issue 13140 .作为一种解决方法,您可以:
<md-input [(ngModel)]="Price" placeholder="Price: {{price|customCurrency"> </md-input>
Price: $1.00 100