Angular 2输入自定义管道 [英] Angular 2 Input Custom Pipe

查看:86
本文介绍了Angular 2输入自定义管道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在Angular 2的输入文本中使用货币或自定义管道?

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

我试过这个:

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

但没有成功

推荐答案

即使在角度1中,也无法在输入中使用管道。

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

您要查找的是掩码指令。
对于angular1,有许多指令,如 ngMask angular-input-masks 等。

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现在正在发布候选版本(06/02/2016),因此只有一些指令。

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.

这篇关于Angular 2输入自定义管道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆