簡體   English   中英

對於像 (25) 和 angular 百分比這樣的數字,限制為 2 個小數位 pipe

[英]Limit to 2 decimal places for a number like (25) with angular percentage pipe

我想將數字轉換為百分比格式,如 25 到 25.00% 和 angular 百分比 pipe。我用過這個。

{{ number | percent : '0.2-2'}}

我變得像這樣 2,500.00%。任何人都可以幫助我嗎?

可能您正在大量使用它,請在 stackblitz 上查看此示例。 請記住1等於100% ,因此要顯示25% ,您需要輸入0.25

另外,檢查文檔和他們的例子,應該是毫無疑問的

https://stackblitz.com/edit/angular-ivy-iszurj?file=src%2Fapp%2Fapp.component.html

https://angular.io/api/common/PercentPipe

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM