如何根据选择的选项更改值?
问题描述:
我正在构建一个Ionic应用程序,并且遇到与我的应用程序的“购物车”页面有关的问题。如何根据选择的选项更改值?
我尝试动态显示该项目的价格时选择的选项:
<form id="itemOrder-form2" class="list">
<label class="item item-input" id="itemOrder-input13">
<span class="input-label">Quantity</span>
<input type="number" placeholder="1">
</label>
<ion-checkbox id="itemOrder-checkbox1">With option 1 (+$2)</ion-checkbox>
<ion-checkbox id="itemOrder-checkbox2">With option 2 (+$2)</ion-checkbox>
<ion-checkbox id="itemOrder-checkbox3">With option 3 (+$2)</ion-checkbox>
<label class="item item-input" id="itemOrder-input4">
<input type="text" placeholder="Add some notes...">
</label>
<div class="spacer" style="width: 300px; height: 33px;"></div>
<a ui-sref="menu2.menu" id="itemOrder-button3" class="button button-dark button-block">Add to cart ($15)</a>
</form>
我怎么能在我的按钮更新总价添加到基于期权车($ 15)的用户蜱和他选择的数量?
答
使用NG-模型的复选框,并在添加到购物车款使用该模型,
<ion-checkbox ng-model="price" id="itemOrder-checkbox1">With option 1 (+$2)</ion-checkbox>
然后
<a ui-sref="menu2.menu" id="itemOrder-button3" class="button button-dark button-block">Add to cart {{price}}</a>
你好,所以我做一个控制器,改变基于价格选项选择?谢谢 – FrenchyNYC
@FrenchyNYC你不必在控制器上做任何事情,只要你改变价格模型就会更新 – Sajeetharan
......我不确定要理解,因为如果我在我的三个复选框上写上“ng-model =”price“”,在按钮中写入“True”或“False”,如果我选择一个,它将同时选择三个。 你能帮我解码吗,我是初学者。预先感谢您 – FrenchyNYC