在角绑定数学函数 [英] Math functions in angular bindings

查看:100
本文介绍了在角绑定数学函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用的数学函数角度绑定的方式?

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

例如。

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

这拨弄说明问题了。

http://jsfiddle.net/ricick/jtA99/1/

推荐答案

您必须注入数学进入你的范围内,如果你需要使用它作为
$范围一无所知数学。

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.

这篇关于在角绑定数学函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆