3

さまざまなStackoverflowリソースを確認した後も、これを行う角度の仕方はまだ分かりません。 Id列と別のテキスト列(入力ボックス)だけを持つHTML表は、ng-repeatを使用して動的に移入されます。次に、入力ボックス内に表示されている個々のレコードの "更新"と "削除"機能/ボタンを提供します。 'Delete'関数は 'delete'ボタンをクリックするとOKと思われます。私は引数として関数にIDを渡します。 'update' clickイベントでは、入力ボックスの値を2番目の引数として関数に渡す方法がわかりません。以下の簡略化されたマークアップとコードをご覧ください。AngularJS - ボタンクリック時にダイナミックテーブルの入力ボックスの値を更新する

<tr ng-repeat="rec in allRecords"> 
    <td>{{rec.Id}}</td> 
    <td> 
     <button ng-click="update(rec.Id, HERE_TEXT_FROM_SIBLING_INPUT')">Update</button> 
     <input type="text" value="{{rec.Name}}"> 
     <button ng-click="deleteMonitorGroup(rec.Id)">Delete</button> 
    </td> 

とコントローラ

app.controller('MyCtrl', function (MyService, $scope) { 

MyService.listAllRecords(function (allRecs) { 
    $scope.allRecords= allRecs; 
}); 

$scope.update = function (Id, text) { 

     MyService.update(Id, text, function() { 
      // update record 
     }); 
} 

}); 

すべてのヘルプは高く評価されます。 feature.Thenを結合角度の2つの方法によって更新rec.Nameを保つng-model="rec.Name"などの入力フィールド上の

答えて

3

使用がng-modelはただそれをより簡単にするための関数呼び出しにrecオブジェクトを渡すではなく、更新機能ORng-modelrec.Nameを渡すん。あなたの助けと非常に迅速に答えを

マークアップ

<tr ng-repeat="rec in allRecords"> 
    <td>{{rec.Id}}</td> 
    <td> 
     <button ng-click="update(rec)">Update</button> 
     <input type="text" ng-model="rec.Name"> 
     <button ng-click="deleteMonitorGroup(rec.Id)">Delete</button> 
    </td> 
</tr> 
+0

おかげで、すべての今正常に動作します! – user2217057