我有两个不同值的变量
{{ timelineExpectedAmount }} //1.996.626,32
和
{{ customTimelineExpectedAmount }} //6.104,77
我想知道,如何计算 customTimelineExpectedAmount
来自 timelineExpectedAmount
的百分比。
我试过这个:{{ timelineExpectedAmount/100 * customTimelineExpectedAmount }}
但没有成功。
有什么提示吗?预期结果是 0.30%
最佳答案
其实更像是一道数学题...
var perc = 6104.77 / 1996626.32 * 100;
console.log(perc); // 0.3057542585134308
或者,在您的情况下:
{{ customTimelineExpectedAmount / timelineExpectedAmount * 100 }}
您可能想要 round the result .
关于javascript - 用angularJS计算百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40752155/