Is there a way to use math functions in AngularJS bindings?
e.g.
The percentage is {{Math.round(100*count/total)}}%
Either bind the global Math object onto the scope (remember to use $window not window)
$scope.abs = $window.Math.abs;
Use the binding in your HTML:
Distance from zero: {{abs(distance)}}
Or create a filter for the specific Math function you're after:
module.filter('abs', ['$window', function($window) {
return function(n) {
return $window.Math.abs($window.parseInt(n));
};
});
Use the filter in your HTML:
Distance from zero: {{distance | abs}}