您正在使用firebase和angularfire作为帐户网络应用的支持,
我有问题设计逻辑来处理这个功能
在ng重复表中获取对象
$将对象范围限定为表单 - 并允许编辑
将更新的$ scope保存到对象(//可能是对象键或$ id
$scope.records = $firebaseArray(data_records);
// updating value
$scope.updateValue = {};
$scope.key = null;
$scope.showDoUpdate = false;
$scope.openUpdate = function(record, key) {
$scope.showDoUpdate = true;
$scope.updateValue.customerCode = record.customerCode;
$scope.updateValue.credit = record.credit;
$scope.updateValue.debit = record.debit;
$scope.updateValue.property_no = record.property_no;
$scope.updateValue.arrears = record.arrears;
$scope.updateValue.closingBlance = record.closingBlance;
$scope.key = key;
};
$scope.closeUpdate = function() {
$scope.records[key] = $scope.updateValue;
$scope.records.$save();
$scope.updateValue = {};
$scope.key = null;
$scope.showDoUpdate = false;
};
和我的HTML
<tbody>
<tr ng-repeat="(key,record) in records">
<td>{{records.customerCode}}</td>
<td>{{records.property_no}}</td>
<td>
<button class="btn" ng- click="openUpdate(key,record)">edit</button>
</td>
<!--form ...........
<button ng-click="closeUpdate()" class="btn ">Save</button>
答案 0 :(得分:0)
$ index会帮助你。尝试类似......
ng-repeat="rec in records"
然后在你的ng-click中:
ng-click="openUpdate(records[$index].record, records[$index].key)"
这会叫...
$scope.openUpdate = function(record, key) {
$scope.key = key;
//other work
};