0
如何向「保存」事件發送完整對象,包括用戶在該行中輸入的內容?現在,無論我做什麼,這兩個字段總是空的。從角度獲取可編輯的數據行並將其發送到WEB api
(the temp comment)我把這個放在哪裏?我想在單擊「保存」時獲取項目數據,但是如果我將它放在那裏,我該如何參考特定行?
我開始使用單獨的頁面進行列表/編輯的例子,所以我遇到的問題是如何將功能組合到一個頁面中。
var ListCtrl = function($scope, $location, Msa) {
$scope.items = Msa.query();
//temp: since I do not know how to get the value for specific row
var id = 1;
$scope.msa = Msa.get({id: id});
$scope.save = function() {
Msa.update({id: id}, $scope.msa, function() {
$location.path('/');
});
}
};
<tbody>
<tr ng-repeat="msa in items">
<td>{{msa.PlaceId}}</td>
<td>{{msa.Name}}</td>
<td>
<div class="controls">
<input type="text" ng-model="msa.PreviousPlaceId" id="PreviousPlaceId">
</div>
</td>
<td>
<div class="controls">
<input type="text" ng-model="msa.NextPlaceId" id="NextPlaceId">
</div>
</td>
<td>
<div class="form-actions">
<button ng-click="save()" class="btn btn-primary">
Update
</button><i class="icon-save"></i>
</div>
</td>
</tr>
</tbody>
另一種方式來引用,而不是通過它我可以使用this關鍵字是嗎? var id = this.msa.PlaceId; – punkouter