每个示例看起来都应该有效,所以我会快速完成。
//点击表格行
纳克单击= “setBill(票据)”
$scope.setBill = function (bill) {
$scope.selectedBill = angular.copy(bill); // shouldn't this set a deep copy?
alert($scope.selectedBill.meterNumber); // Outputs properly
}
//点击按钮
纳克单击= “btnInsertData()”
$scope.btnInsertData = function () {
alert($scope.selectedBill.meterNumber); // $scope.selectedBill is undefined
return;
}
//从上面的html请求调用
<tr ng-repeat="bill in billItems" ng-click="setBill(bill)" ng-class="{'selected':bill.meterNumber == selectedBill.meterNumber}">
...
<td>{{bill.meterNumber}}</td>
...
</tr>
...
<button ng-click="btnInsertData()">Submit to VP</button>