如何在AngularJs中格式化货币

时间:2014-05-01 14:49:04

标签: angularjs

我想尝试使用Angular在输入中格式化货币。我试过这样做:

<input type="text" ng-disabled="controller.enableListPrice()" ng-model="controller.data.ListPrice" value="{{controller.data.ListPrice|currency}}"/>

However it allows me to type only one number with the currency format.

For instance if I type 123, I see 1.00$, 2.00$, 3.00 $ flicker.

If I type 123 I need to see: 123$.

Any Suggestions and ideas.

1 个答案:

答案 0 :(得分:0)

您每次都要替换输入值。设置输入值时,它会更改输入字段中的文本,当您继续键入时,会再次覆盖它。您可以在单独的范围内显示输入,如下所示:

<input type="text" ng-disabled="controller.enableListPrice()" ng-model="controller.data.ListPrice">
<span> {{controller.data.ListPrice|currency}}</span>

如果你真的想在输入中显示货币值,可以使用一些JS / CSS来显示输入前面的跨度并隐藏下面的实际输入值。

相关问题