Javascript ngRepeat中的AngularJS绑定问题(折叠和扩展插入符号)
我正在尝试以一种重复的方式实现折叠和扩展面板。我试过这个:Javascript ngRepeat中的AngularJS绑定问题(折叠和扩展插入符号),javascript,angularjs,twitter-bootstrap,Javascript,Angularjs,Twitter Bootstrap,我正在尝试以一种重复的方式实现折叠和扩展面板。我试过这个: <tbody ng-repeat="item in Items"> <tr data-toggle="collapse" class="accordion-toggle"> <td>{{item.name}}</td> <td> <a class="dropdown-toggle" ng-click="isColla
<tbody ng-repeat="item in Items">
<tr data-toggle="collapse" class="accordion-toggle">
<td>{{item.name}}</td>
<td>
<a class="dropdown-toggle" ng-click="isCollapsed = !isCollapsed;getDetails(item.id);" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><span class="caret"></span></a>
</td></tr>
<tr>
<td class="hiddenRow">
<div class="accordian-body collapse" collapse="isCollapsed">
<table class="table display" style="border-collapse:collapse;">
<thead><tr>
<th>Student Name</th><th>Roll Number</th></tr></thead>
<tbody>
<tr>
<td>{{studentRecord.patientName}}</td><td>{{studentRecord.rollNumber}}</td>
</tr></tbody></table>
</div>
</td>
</tr>
</tbody>
当我在ngRepeat中单击单插入符号按钮时,它工作正常。但是,当我单击多个项目时,repeater会为每个项目创建一个作用域。因此,ngRepeat中的所有记录都获得相同的范围值。如何解决此问题。U应将项中的属性设置为
item.studentRecord
然后使用
获取详细信息(项目)
$scope.getDetails=函数(项)
{
var studentDetails=DetailService.getDetail(“studentsDetails”,item.id);
studentDetails.then(函数(数据){
item.studentRecord=数据;
});
}
{{item.studentRecord.patientName}
{{item.studentRecord.rollNumber}
您是否要求$scope.studentRecord=数据;是否始终相同?否。当我展开多个记录时,$scope.studentRecord为所有记录附加相同的值。请尝试使用下面的代码:)
item.studentRecord
$scope.getDetails = function (item)
{
var studentDetails = DetailService.getDetail("studentsDetails", item.id);
studentDetails.then(function(data) {
item.studentRecord = data;
});
}
<td>{{item.studentRecord.patientName}}</td>
<td>{{item.studentRecord.rollNumber}}</td>