Math functions in AngularJS bindings

后端 未结 13 1131
无人及你
无人及你 2020-11-29 17:55

Is there a way to use math functions in AngularJS bindings?

e.g.

The percentage is {{Math.round(100*count/total)}}%

相关标签:
13条回答
  • 2020-11-29 18:45

    Better option is to use :

    {{(100*score/questionCounter) || 0 | number:0}}
    

    It sets default value of equation to 0 in the case when values are not initialized.

    0 讨论(0)
提交回复
热议问题