2016-10-05 4 views
0

私は3つの入力を持っていますが、2つの入力で値を減算し、結果の入力をバインドしています。しかし、私は、ボタンのクリックに新しい行を追加したい、私はTRでNGリピートを与えることなく、HTMLで計算値の結果の取得と新しい行の追加方法

https://jsbin.com/qutuyodite/edit?html,js,output 

答えて

0
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({ 
      }); 
     } 

    } 

<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> 

ここ

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({ 
      }); 
     } 

    } 


}); 

検索コードを動作していない試してみました作業中JSBin

+0

あなたの質問や問題に直面していますか? –

+0

ありがとうravi、私の要件では、私はここに繰り返しとコードの側にボタンを追加しているhttps://jsbin.com/repanijitu/edit?html,js,output –

+0

あなたはあなたには、ボタン? –

関連する問題