The example is a="2,322.222",b='1,211.21', how to perform subtraction in angualr
怪我咯2017-05-16 13:46:20
function(a, b) {
a = a.replace(',', '');
b = b.replace(',', '');
return (+a - +b).toFixed(2);
}
过去多啦不再A梦2017-05-16 13:46:20
Use split(',') and press ',' to divide it into multiple arrays and judge based on the length. For example, a is 21000 and b is 11000. If there are more commas, it is judged based on the length. If the length is 3, the subscript is When 0 is 10001000, consider the Math.pow(10,n * 3) method and convert it into numbers for subtraction. You can try it