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