有没有办法在angular2绑定中使用数学函数?
例
<div class="partition-panel">
<b class="pull-left">{{Math.round(variable/12*2)}}</b>
<b class="pull-right">{{Math.round(variable/12*2)}}</b>
</div>
当尝试使用此时,我得到了错误
Cannot read property 'round' of undefined
也为angular1回答了类似的问题
您可以尝试以下方法:
@Component({
selector: 'my-app',
template: `
<div>
<h2>Hello {{math.round(number)}}</h2>
</div>
`,
})
export class App {
number = 2.5;
math = Math;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句