uhlryk / angular-dynamic-number

Highly customizable angular directive for numbers
64 stars 32 forks source link

Have more thousand sep when currency 2 character more #54

Closed voicoi84 closed 7 years ago

voicoi84 commented 7 years ago

I am using currency malaysia RM and have problem when price RM800,000 (expect) now RM,800,000 please check

Thank Trong

voicoi84 commented 7 years ago

Sorry I fixed it but dont know you can agree ? function addThousandSeparator(value, fractionSeparator, thousandSeparator){ value = String(value).split(fractionSeparator); value[0] = value[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator); if (value[0].indexOf(thousandSeparator) > 0){
var temp = value[0]; var res = temp.substr(temp.indexOf(",")-1,temp.length - 1); res = res.substr(res.indexOf(",")-1,res.indexOf(","));
if (isNaN(res)){ value[0] = temp.substr(0, temp.indexOf(",")) + temp.substr(temp.indexOf(",")+1); }
} return value.join(fractionSeparator); }

uhlryk commented 7 years ago

I appreciate your involvement. Unfortunately Im a little against making more advanced functionality related to suffix and prefix characters. This component is for processing numbers. Current suffix and prefix functionality had purpose to help only in simplest cases. Personally I would even remove those at all. It is possible very easy add them with small chunk of css (maybe also a little of js). Of course if you feel that this component should evolve in direction you suggested then I would be proud if you fork it and make it better. Because my decisions are mostly because not sufficient time to extent this module in all possible direction.