0
我有三個輸入,我在兩個輸入減去值和結果輸入結合的結果。但我想在點擊按鈕添加新行,我試圖讓納克重複在TR而不是在這裏工作如何獲得計算值產生,並添加新行
https://jsbin.com/qutuyodite/edit?html,js,output
我有三個輸入,我在兩個輸入減去值和結果輸入結合的結果。但我想在點擊按鈕添加新行,我試圖讓納克重複在TR而不是在這裏工作如何獲得計算值產生,並添加新行
https://jsbin.com/qutuyodite/edit?html,js,output
ReceiptsApp.controller('ReceiptsController', function ($scope) {
$scope.rvm = [{}];
$scope.addRow1 = function (index, r) {
// pass the particular array object on which you want to perform calculations when the function is called from ng-click and access those particular objects values using r.val1 and r.val2
//Access particular "rvm" object using index
$scope.rvm[index].result = r.val1 - r.val2;
if ($scope.rvm.length == (index + 1)) {
$scope.rvm.push({
});
}
}
var ReceiptsApp = angular.module('ReceiptsApp', []);
ReceiptsApp.controller('ReceiptsController', function ($scope) {
$scope.rvm = [{}];
$scope.addRow1 = function (index) {
//alert('ss');
$scope.result = $scope.r.val1 - $scope.r.val2;
if ($scope.rvm.length == (index + 1)) {
$scope.rvm.push({
});
}
}
});
查找代碼在HTML
<td>
<input type="text" lass="input-large" ng-model="r.result" name="res" />
</td>
<td>
<button type="button" class="btn btn-default" ng-click="addRow1($index, r)">Add</button>
</td>
工作JSBin
是否回答你的問題或你是否面臨任何問題? –
謝謝拉維,在我的要求,我有添加按鈕出NG重複和代碼在這裏https://jsbin.com/repanijitu/edit?html,js,output的側 –
你是說你只想有'one'添加按鈕? –