如何在AngularJs中设置货币格式
我想尝试使用Angular在输入中格式化货币。我试着这样做:如何在AngularJs中设置货币格式,angularjs,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 f
<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.
但是,它只允许我键入一个货币格式的数字。
例如,如果我键入123,我会看到1.00$、2.00$、3.00$闪烁。
如果我输入123,我需要看到:123$。
任何建议和想法。
每次都要替换输入值。当您设置输入值时,它会更改输入字段中的文本,当您继续键入时,会再次覆盖它。您可以在单独的范围内显示输入,如下所示:
<input type="text" ng-disabled="controller.enableListPrice()" ng-model="controller.data.ListPrice">
<span> {{controller.data.ListPrice|currency}}</span>
{{controller.data.ListPrice | currency}}
如果您真的想在输入中显示货币值,您可以使用一些JS/CSS在输入前面显示跨度,并在下面隐藏实际输入值。非常感谢。我想在输入中显示货币。我该怎么做呢。有很多方法可以做到这一点,但这里有一个建议,可以编写一个对我有意义的自定义指令: