2015-11-10 47 views
0

我有一個數字輸入字段,當使用上/下按鈕增加或減少號碼或用戶鍵入價格時,我想要顯示我的價格的實時更新。這是我到目前爲止。它如何瞄準這樣做? 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> 

控制器

$scope.goPrice = function(quant){ 
    $scope.total= quant * 9.99 
    console.log($scope.total) 
} 

回答

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()"