Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

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

e.g.

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

This fiddle shows the problem

1 Answer

0 votes
by (106k points)
edited by

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

Want to learn Angularjs from scratch! Have a look at this video on Angularjs provided by Intellipaat:

The simplest way, you can do

$scope.Math = window.Math;

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

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...