ngx currency
v18.0.0
https://nbfontana.github.io/ngx-currency/
按命令安装软件包:
npm install ngx-currency --save导入指令
import { NgxCurrencyDirective } from "ngx-currency" ;
@ Component ( {
standalone : true ,
selector : "app-root" ,
templateUrl : "./app.component.html" ,
imports : [ NgxCurrencyDirective ] ,
} )
export class AppComponent { } < input type =" tel " currencyMask formControlName =" value " />ngModel类型号的属性。如果显示为'$ 25.63' ,则属性为'25.63' 。您可以设置选项...
<!-- example for pt-BR money -->
< input [currencyMask] =" { prefix: 'R$ ', thousands: '.', decimal: ',' } " formControlName =" value " />可用选项:
align - 输入中的文本对齐。 (默认: right )allowNegative如果true可以输入负值。 (默认: true )decimal - 小数的分离器(默认: '.' )precision - 十进制位置的数量(默认值: 2 )prefix - 货币前缀(默认值: '$ ' )suffix - 金钱后缀(默认: '' )thousands - 成千上万的分离器(默认: ',' )nullable - 当true时,清洁字段的值将为null ,当false时值为0min - 最小值(默认值: undefined )max - 最大值(默认值: undefined )inputMode确定如何处理用户键入数字(默认: Financial )输入模式:
Financial - 数字从最高的十进制开始。键入数字移动数字。十进制特征被忽略。大多数现金寄存器以这种方式工作。例如:'12'结果为'0.12''1234'导致'12.34''12.34'中键入'1.234'结果Natural - 数字从十进制的左侧开始。在小数偏移的左侧键入一个数字;在小数的右侧打字将替换下一个数字。大多数文本输入和电子表格以这种方式工作。例如:'1234'导致'1234''1.234'导致'1.23''12.34'导致'12.34''123.4'结果”中的'123.40'您还可以在全球设置选项...
import { provideEnvironmentNgxCurrency , NgxCurrencyInputMode } from 'ngx-currency' ;
bootstrapApplication ( AppComponent , {
providers : [
...
provideEnvironmentNgxCurrency ( {
align : "right" ,
allowNegative : true ,
allowZero : true ,
decimal : "," ,
precision : 2 ,
prefix : "R$ " ,
suffix : "" ,
thousands : "." ,
nullable : true ,
min : null ,
max : null ,
inputMode : NgxCurrencyInputMode . Financial ,
} ) ,
...
] ,
} ) . catch ( ( err ) => console . error ( err ) ) ; npm install当前目录是此存储库运行npm start启动开发服务器。
npm test进行测试在Chrome浏览器中运行时,您可以使用以下说明将代码断点设置为调试测试:
Debug按钮以打开调试窗口ctrl + shift + i打开Chrome Developer工具ctrl + p搜索文件进行调试input.handler.ts类的文件名,然后单击文件MIT @ neri bez fontana