ricick ricick - 2 years ago 189
AngularJS Question

Math functions in angular bindings

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


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

This fiddle shows the problem


Answer Source

You have to inject Math into your scope, if you need to use it as $scope know nothing about Math.

Simplest way, you can do

$scope.Math = window.Math;

in your controller. Angular way to do this correctly would be create a Math service, I guess.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download