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
Post a Comment