【发布时间】:2015-09-22 18:04:12
【问题描述】:
您好,我正在使用 firebase 和 angularfire 作为帐户网络应用程序的后端,
处理此功能的设计逻辑有问题
在 ng 重复表中获取对象
$scope 将对象转换为表单 - 并允许编辑
将更新的 $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>
【问题讨论】: