Math functions in AngularJS bindings

后端 未结 13 1126
无人及你
无人及你 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.

提交回复
热议问题