Math functions in angular2 bindings
Is there a way to use math functions in angular2 bindings?
Example
<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> when i try to use this i got an error
Cannot read property 'round' of undefined Also a similar question is responsible for angular1
+7
Jagadeesh govindaraj
source share1 answer
You can try the following:
@Component({ selector: 'my-app', template: ` <div> <h2>Hello {{this.Math.round(this.number)}}</h2> </div> `, }) export class App { number: number; Math: any; constructor() { this.Math = Math; this.number = 2.5 } } +26
Adrien barral
source share