Angular 角6键自动货币
我试图在输入元素中使用keyup,并在Angular 8中使用currency pipeAngular 角6键自动货币,angular,Angular,我试图在输入元素中使用keyup,并在Angular 8中使用currency pipe <input placeholder="€0.00" (keyup)="onKey(pointIndex, $event.target.value, item.quantity)" value="{{item.unitPriceWithVat | currency:currency_code:'symbol-narrow':'1.2-2'}}"/> 当我在里面写一些数字时,它会自动格式化为
<input placeholder="€0.00" (keyup)="onKey(pointIndex, $event.target.value, item.quantity)" value="{{item.unitPriceWithVat | currency:currency_code:'symbol-narrow':'1.2-2'}}"/>
当我在里面写一些数字时,它会自动格式化为200.00或1230.00,但问题是,如果我尝试在输入中写一些数字,假设12345.00,它会将数字格式化为如下内容:12.34
演示
谁能帮我解决这个问题!
提前感谢 问题出在您的
onKey
函数中,这行代码如下:
let priceValue = parseFloat(price.replace(/[^0-9.,]+/g, ''));
parseFloat
将类似12345.00的值转换为12
。您需要更改此行以替换,
let priceValue = parseFloat(price.replace(/[^0-9.]+/g, ''));
你能用分享一个演示吗?嗨,演示在这里,试着写一个价格你的键是什么
?你能提供一个例子吗?你可以在开发者界面上看到Console@youri嘿,我添加演示我需要提供什么样的示例