所以我试图将单选按钮绑定到对象。我花了大约一个小时试图弄清楚这一点,最后承认失败。这是我得到的:
<table>
<tr ng-repeat="theCustomer in customers">
<td>
<input type="radio" ng-model="currentCustomer" value="theCustomer" id="{{theCustomer.id}}" ng-change="currentCustomer = theCustomer">
<label for="{{theCustomer.id}}">{{theCustomer.name}}</label>
</td>
</tr>
</table>
棱角分明的东西:
bankApp.controller("BankController", function ($scope, CustomerRepository)
{
$scope.customers = [];
$scope.currentCustomer = {};
$scope.createCustomer = function () {
CustomerRepository.save($scope.customer, function (customer) {
$scope.customers.push(customer);
$scope.customer = {};
});
};
});
目前,当我尝试单击单选按钮时,没有任何反应,甚至没有得到检查。我确信必须有一个非常简单的解决方案。最终目标是让currentCustomer
客户反映在无线电选择中。