我有以下目的:角形式設置變量等於表達式
$scope.module.discount = [{
licences: 0,
discountPercentage: 0,
new_value_pr_licence: 0
}]
和以下簡單形式:
<div class="form-group">
<label>Pris pr licens</label>
<div class="input-group m-b">
<input type="number" class="form-control" ng-model="module.price_pr_licence">
<span class="input-group-addon">Kr</span>
</div>
</div>
<div class="col-xs-12">
<table>
<thead>
<th>Licenser</th>
<th>% rabat</th>
<th>Ny pris pr stk</th>
</thead>
<tbody>
<tr ng-repeat="discount in module.discount">
<td>
<input class="form-control" ng-model="discount.licences" type="number" required="">
</td>
<td>
<input class="form-control" type="number" ng-model="discount.discountPercentage" required="">
</td>
<td>
<button class="btn btn-sm btn-default">{{module.price_pr_licence * (1-(discount.discountPercentage/100))}}</button>
</td>
</tr>
</tbody>
</table>
</div>
AS可以看到該按鈕的值是一個表達式:
{{module.price_pr_licence * (1-(discount.discountPercentage/100))}}
現在我想確定:
discount.new_value_pr_licence = module.price_pr_licence * (1-(discount.discountPercentage/100))
但我不太清楚如何做到這一點。
如何將變量綁定到這樣的表達式?
設置它什麼時候?點擊按鈕?你可以這樣做,如果這樣的話:ng-click =「discount.new_value_pr_licence = module.price_pr_licence *(1-(discount.discountPercentage/100))」 – BBauer42
@ BBauer42該按鈕不被點擊(我知道這個升技不清楚)但基本上每當表達改變折扣的價值應該設置 –