如何选择任何数量及其价值得到改变? [英] How To select any quantity and it's value get's changed?
本文介绍了如何选择任何数量及其价值得到改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Ionic 3的新手,想了解代码,请帮帮我.我想选择任何项目,并且它的值get的更改小计可能反映了它的输出.
I am new to ionic 3 and want to know about the code please help me out guy's. I want to select any item and it's value get's changed subtotal may reflect's to it output.
购物车
private _values1 = [" 1 ", "2", " 3 "," 4 "," 5 "," 6 "];
firstDropDownChanged(_values1: any)
{
this.currentPrice = (parseInt(this.product.subtotal) * this._values1);
console.log(this.currentPrice);
this.product.subtotal =this.currentPrice;
console.log(this.product._values1);
}
cart.html
<span style="font-size: 14px !important;">Qty:</span>
<select class="sel" (change)="firstDropDownChanged()">
<option *ngFor='let v of _values1'>{{ v }}</option>
</select>
推荐答案
您可以使用 [(ngModel)]
as
<select class="sel" (change)="firstDropDownChanged()" [(ngModel)]="selectedValue">
<option *ngFor='let v of _values1' [ngValue]="v">{{ v }}</option>
</select>
因此,每次更改选项时,所选选项的当前值都将位于 selectedValue
变量中.在 .ts
文件中用作
So, on every change of option, the current value of selected option will be in selectedValue
variable. Use in .ts
file as
firstDropDownChanged() {
this.currentPrice = this.product.subtotal * this.selectedValue;
console.log(this.currentPrice);
this.product.subtotal =this.currentPrice;
}
Stackblitz Demo using ngModel
这篇关于如何选择任何数量及其价值得到改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文