Math functions in AngularJS bindings

后端 未结 13 1197
无人及你
无人及你 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:34

    If you're looking to do a simple round in Angular you can easily set the filter inside your expression. For example:

    {{ val | number:0 }}

    See this CodePen example & for other number filter options.

    Angular Docs on using Number Filters

提交回复
热议问题