我有一个数字输入字段,我想显示我的价格的实时更新,当使用向上/向下按钮增加或减少数字或用户输入价格时。这是我到目前为止所拥有的。它如何以此为目标? HTML
<table>
<tr>
<td>QUANTITY: <input type="number" style="width: 50px "ng-model="quant" ng-init="quant = 1"/></td>
<td>TOTAL:{{total}}</td>
<td><button ng-click="goPrice(quant)">PRICE</button></td>
</tr>
</table>
CONTROLLER
$scope.goPrice = function(quant){
$scope.total= quant * 9.99
console.log($scope.total)
}
答案 0 :(得分:0)
也许这可以帮到你
<input
ng-model="string"
[name="string"]
[required="string"]
[ng-required="boolean"]
[ng-minlength="number"]
[ng-maxlength="number"]
[ng-pattern="string"]
[ng-change="expression"]
[ng-trim="boolean"]>
...
</input>
特别是这个
[ng-change="expression"]
ng-change="change()"