因此,我在具有ng-options的视图中进行了选择。我还有一个名为 CourseID 的变量。我试图显示课程 CourseID 与前面提到的变量中的 CourseID 不同。
这是我的代码
JS
$scope._data.courses = [
{
"FullName": "Math",
"CourseID": 1
},
{
"FullName": "History",
"CourseID": 2
},
{
"FullName": "PE",
"CourseID": 3
},
{
"FullName": "Literature",
"CourseID": 4
}
]
$scope.data.trainees = [
{
"FullName": "Jame Pierre",
"ID": 54
},
{
"FullName": "Marie Cullan",
"ID": 78
},
{
"FullName": "Joseph Matthews",
"ID": 33
},
{
"FullName": "Jean Paul",
"ID": 15
}
]
$scope._data.CurrentCourseID = 2;
查看
<tr ng-repeat="trainee in _data.trainees">
<td>{{trainee.ID}}</td>
<td>{{trainee.FullName}}</td>
<td>
<select class="form-control selectpicker" ng-options="course.CourseID as course.Name for course in _data.courses | filter:{ CourseID : '!' + _data.CurrentCourseID }:true" ng-model="CID" ng-change="moveTo(trainee, CID)">
<option style="display:none" value="">Move to</option>
</select>
</td>
<td ng-init="$last && refreshPickers()">
<div style="float: right;">
<a class="btn btn-danger" ng-click="remove(trainee)">
<i class="fa fa-trash"></i>
</a>
</div>
</td>
</tr>
它仍然无法按预期工作。第一种方式不显示任何课程,第二种方式显示所有课程。