AnglurJS將金額轉換為大寫金額

2021-07-29 10:13:07 字數 2414 閱讀 9732

class="font-small"

style="">

}div>

後台**:

$scope.milestone.winbiddate

=new

date();

前台就會顯示出這種效果來:

根據相同的原理我做了乙個阿拉伯數字轉換大寫數字的過濾convertcurrencyfilter

過濾的**如下:

() // validate input string:

currencydigits = currencydigits.tostring();

if (currencydigits == "")

if (currencydigits.match(/[^,.\d]/) != null)

if ((currencydigits).match(/^((\d(,\d)*(.((\d,)*\d))?)|(\d+(.\d+)?))$/) == null)

// normalize the format of input digits:

currencydigits = currencydigits.replace(/,/g, ""); // remove comma delimiters.

currencydigits = currencydigits.replace(/^0+/, ""); // trim zeros at the beginning.

// assert the number is not greater than the maximum number.

if (number(currencydigits) > maximum_number)

// process the coversion from currency digits to characters:

// separate integral and decimal parts before processing coversion:

parts = currencydigits.split(".");

if (parts.length > 1)

else

// prepare the characters corresponding to the digits:

digits = new

array(cn_zero, cn_one, cn_two, cn_three, cn_four, cn_five, cn_six, cn_seven, cn_eight, cn_nine);

radices = new

array("", cn_ten, cn_hundred, cn_thousand);

bigradices = new

array("", cn_ten_thousand, cn_hundred_million);

decimals = new

array(cn_ten_cent, cn_cent);

// start processing:

outputcharacters = "";

// process integral part if it is larger than 0:

if (number(integral) > 0)

else

zerocount = 0;

outputcharacters += digits[number(d)] + radices[modulus];

}if (modulus == 0 && zerocount < 4)

}outputcharacters += cn_dollar;

}// process decimal part if there is:

if (decimal != "") }}

// confirm and return the final output string:

if (outputcharacters == "")

if (decimal == "")

outputcharacters = outputcharacters;

return outputcharacters;

}}當你將這段**加入你的js的時候你就可以直接使用它

前台:

style="position: absolute;top:22px;font-size: 0.8rem">

}span>

後台:

$scope.summoneynum=3000
介面就會顯示:

希望對大家有幫助,謝謝!

將數值金額轉換為中文大寫金額

將數值金額轉換為中文大寫金額 param amount float 金額 支援到分 param type int 補整型別,0 到角補整 1 到元補整 return mixed 中文大寫金額 function convertamounttocn amount,type 1 金額為0,則直接輸出 零元...

將數字轉換為大寫金額

export const changetochinese num num num.replace g,替換tomoney 中的 num num.replace g,替換tomoney 中的空格 num num.replace g,替換掉可能出現的 字元 if isnan num 字元處理完畢後開始轉...

java將金額轉換為大寫中文

public class numberutil private static final string num 將金額小數轉換成中文大寫金額 param money return result public static string test2 double money else result r...