angular2 template - How can I get the calculated field work in Angular 2? -


i trying data calculated field

export class position {    securityid: number;    securityname: string;    tradecount: number;    avgprice: number;    quantity: number;       constructor () {}      public marketvalue(): number {         return this.avgprice * this.quantity;     } } 

and tryinhg bind fields work fine calculated marketvalue not

td>{{ position.marketvalue | currency:"usd":true:"1.2-2"}}</td> 

the table cell shows empty. following work

td>{{ this.quantity * this.avgprice | currency:"usd":true:"1.2-2"}}</td> 

how can caclcualed property work? thanks!

export class position {    securityid: number;    securityname: string;    tradecount: number;    avgprice: number;    quantity: number;    marketvalue: number;      constructor () {}      ngonchanges(change)  {         this.marketvalue = this.avgprice * this.quantity;     } } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -