我有一个页面,我需要提交所有需要退休或不退休的员工。我正在尝试显示每个员工的员工姓名和单选按钮列表,并提供退休和不退休选项。
<div class="body" ng-repeat="employee in EmployeesList">
<div class="row" style="padding-left: 15px;">
<label>{{employee.name}}</label>
</div>
<div class="row">
<label class="radio-inline"><input name="radioGroup" type="radio" id="Retired"
checked="checked" ng-model="$parent.status" value="RETIRED"/><strong>RETIRED</strong></label>
<label class="radio-inline"><input name="radioGroup" type="radio" id="NotRetiring"
ng-model="$parent.status" value="NOTRETIRING"/><strong>NOT RETIRING</strong></label>
</div>
</div>
<div class="footer">
<button type="button" class="btn btn-default" ng-click="Submit()">OK</button>
<button type="button" ng-click="cancel()">CANCEL</button>
</div>
Controller:
$scope.EmployeesList = EmployeeService.getEmployeeList();
$scope.Submit = function () {
angular.forEach($scope.EmployeesList, function (employee, index) {
var employeeid = employee.id;
var date = new Date();
var employeeResponse =
{
EmployeeID: employeeid,
DateEntered: date,
Status: $scope.status
}
EmployeeService.Submit(employeeResponse).then(function() {
});
}
});
当我尝试选择每个员工的状态时,无论他是不是退休了,它都不是它应该做的。如果我更改了第二个员工的状态,则第一个员工的状态将丢失其状态。现在,我需要将“退休”作为所有员工的默认选择,并需要根据需要修改每个员工的状态。请帮帮我。
发布于 2016-06-27 03:47:42
您希望记住每个员工的状态,因此可以尝试:
<div class="body" ng-repeat="employee in EmployeesList">
<div class="row" style="padding-left: 15px;">
<label>{{employee.name}}</label>
</div>
<div class="row">
<label class="radio-inline"><input name="radioGroup" type="radio" id="Retired"
checked="checked" ng-model="employee.status" value="RETIRED"/><strong>RETIRED</strong></label>
<label class="radio-inline"><input name="radioGroup" type="radio" id="NotRetiring"
ng-model="employee.status" value="NOTRETIRING"/><strong>NOT RETIRING</strong></label>
</div>
</div>https://stackoverflow.com/questions/38042317
复制相似问题