我是新來AngularJS,我嘗試做以下AngularJS納克 - 重複,納克 - 輸入文字奇怪的行爲模式
var app = angular.module('SomeApp', []);
app.controller('QuotationController', function($scope) {
$scope.init = function(){
$scope.chargableDescription = [""];
$scope.chargablePrice = [];
$scope.chargableQuantity = [];
$scope.chargableTotal = [];
}
$scope.chargableInput = function($last){
if ($last) {
$scope.chargableDescription.push([""]);
}
}
});
基本的代碼,我想在這裏實現的是插入整個用戶在最後一個chargableDescription字段上輸入內容時的輸入組。
<div class="chargable-group" ng-repeat="item in chargableDescription" >
<div class="col-md-3">
<label class="form-control-label" for="l2" id="chargable-label">Chargable Item</label>
</div>
<div class="col-md-9" id="chargable-header">
<textarea name="chargable[]" class="form-control dynamic chargable" placeholder="Chargable Description" ng-model="chargableDescription[$index]" ng-keypress="chargableInput($last)"> </textarea>
<br>
<input type="number" class="form-control" step="0.01" name="chargable-price-1" placeholder="Chargable Price" ng-model="chargablePrice[$index]">
<br>
<input type="number" class="form-control" name="chargable-quantity-1" placeholder="Chargable Quantity" ng-model="chargableQuantity[$index]">
<br>
<input type="number" class="form-control" step="0.01" name="chargable-total-1" placeholder="Chargable Total" readonly ng-model="chargableTotal[$index]" >
</div>
</div>
它的伎倆,但是,我不知道爲什麼,當我做textarea的任何輸入,將光標一次,我輸入一個字符了。 如何消除此行爲以及導致此行爲的因素是什麼?
UPDATE:
解決 我加了NG-模型選項= {updateOn: '模糊'}和它看起來像它解決了問題
請刪除該問題,因爲它總是會顯示爲未答覆,否則當他們開始閱讀時會浪費任何人的時間以解決問題。否則,在標題本身寫[Solved]。 –