vbotio vbotio - 11 days ago 6
Javascript Question

calculate percent with angularJS

I have 2 variables with different values

{{ timelineExpectedAmount }} //1.996.626,32


and

{{ customTimelineExpectedAmount }} //6.104,77


I want to know, how can I calculate how many %
customTimelineExpectedAmount
is from
timelineExpectedAmount
.

I tried this:
{{ timelineExpectedAmount / 100 * customTimelineExpectedAmount }}
but did not work.

any hint ? the expected result is
0.30%

Answer

Really more of a math question...

var perc = 6104.77 / 1996626.32 * 100;

console.log(perc); // 0.3057542585134308


Or, in your case:

{{ customTimelineExpectedAmount / timelineExpectedAmount * 100 }}

You may want to round the result.

Comments