0

I want to show the result of a test:

<span>{{test.correctCount / test.questions}}</span>%

But how can I show this as an integer number correctly rounded?

  • This may help you http://stackoverflow.com/questions/19326610/angular-directive-to-round-a-decimal-number – Vítor Martins Apr 27 '15 at 11:36
  • possible duplicate of [Math functions in angular bindings](http://stackoverflow.com/questions/12740329/math-functions-in-angular-bindings) – Eru Apr 27 '15 at 11:37

3 Answers3

0

According to the documentation:

https://docs.angularjs.org/api/ng/filter/number

You can do it like this:

 {{ number_expression | number : fractionSize}}

Also in this post there is an answer: Math functions in angular bindings (post by Andrew Kuklewicz)

Community
  • 1
  • 1
Eru
  • 332
  • 3
  • 17
0
<span>{{(test.correctCount / test.questions)|number:0}}</span>%
Stu
  • 2,426
  • 2
  • 26
  • 42
0
<span>{{{{test.correctCount / test.questions}} | number:0}}</span>%

Now its upto you ,How you want to show the result.

  • List item

Use number:0 for (96%)

use number:2 if you want to show like that (96.20%)

Hardik Munjaal
  • 93
  • 1
  • 13