我有一个Product
对象,其中有我需要计算的属性。
export class Order {
ProductId: number;
Quantity: number;
Price: number;
PriceTotal: number;
}
当用户选择产品数量(Quantity
)时,我想更新PriceTotal
值,例如:
this.PriceTotal = this.Quantity * this.Price;
我可以在哪里进行操作,以便在用户选择/更改PriceTotal
值时,我的屏幕会更新Quantity
?
答案 0 :(得分:0)
也许这可以帮助您...
export class Order {
ProductId: number;
Quantity: number;
Price: number;
get PriceTotal(){
return this.Quantity * this.Price;
}
}