我有一张桌子,桌子的第一列是单选按钮。我用ng-repeat创建了。点击我必须访问已检查的单选按钮值我无法访问该值的问题。
<div class="panel-heading">
<h3 class="panel-title mainPanelTitle">Future Appointments</h3>
</div>
<div class="panel-body">
<div class="table-responsive noSwipe tableContainer" tasty-table bind-resource="futureAppointmentsMap" bind-filters="filters">
<div class="col-sm-3 tableSearch">
<input type="text" class="form-control input-sm"
placeholder="Search" ng-model="filters" value=""/>
</div>
<table id="tblPatientMyAppointmentsFuture" class="table table-bordered">
<thead tasty-thead bind-not-sort-by="notSortBy"></thead>
<tbody>
<tr ng-repeat="appointment in rows">
<td>
<label class="radio-inline">
<input type="radio" name="rbnTagAppointment" value="{{appointment.id}}" ng-model="selectedAppointmentId">
</label>
</td>
<td ng-class="{{appointment.timeLineId!=0?'tdImage':''}}" data-title="No">
{{$index+1}}
<img ng-if="appointment.timeLineId!=0" ng-src="img/brightfuture_logomedium.png"/>
</td>
<td data-title="Time">
{{changeDateFormat(appointment.date)}}<br>
{{appointment.time}}
</td>
<td data-title="Specialty">
{{appointment.specialtyId=="5"?'Pediatrics':appointment.specialty}}
</td>
<td data-title="Physician">
{{appointment.physicianName}}<br/>
{{appointment.orgName}}
</td>
</tr>
</tbody>
</table>
<div tasty-pagination ng-show="rows.length>0"></div>
<div class="divNoData" ng-show="rows.length==0">
No data available
</div>
<div class="text-center">
<button class="btn btn-default btn-sm" ng-click="tabAppointmentWithImmunization()">Upload</button>
</div>
</div>
</div>
在我的控制器中。
$scope.tabAppointmentWithImmunization = function() {
console.info($scope.selectedAppointmentId);
};
当我打印它显示未定义的值时。
答案 0 :(得分:0)
删除花括号,无需插值:
ng-value="appointment.id"
我还将您的value
属性更改为ng-value
- 与ng-repeat
一起使用。
答案 1 :(得分:0)
如果要绑定$ scope值,请使用ng-value,如果要应用双向绑定,则ng-value和ng-model应该相同。
<input type="radio" name="rbnTagAppointment" ng-value="selectedAppointmentId" ng-model="selectedAppointmentId">