带有选择选项的Angularjs动态表单字段禁用已选择选项

带有选择选项的Angularjs动态表单字段禁用已选择选项,angularjs,Angularjs,嗨,我有一个选择选项动态添加表单字段。我想要的是在新添加的字段中禁用以前选择的选项。 我的html是这样的 <div ng-repeat="exam_student in exam_students track by $index"> <select ng-model="exam_student.student_id" options="students" ng-options="student.id as student.sname for

嗨,我有一个选择选项动态添加表单字段。我想要的是在新添加的字段中禁用以前选择的选项。 我的html是这样的

<div ng-repeat="exam_student in exam_students track by $index">

   <select 
    ng-model="exam_student.student_id"
    options="students"
    ng-options="student.id as student.sname for student in students">
  </select>
  <button type="button" ng-click="removeStudent($index)">-</button>

</div>

<button type="button" ng-click="addStudent()">+</button>
这是普朗克

谢谢你的帮助和建议。

试试这把小提琴

否则,您可以调用
$scope.filterStudents()它将按选择筛选数组

$scope.filterStudents = function (){
      $scope.filteredstudents = $scope.students.filter( function( el ) {
        return !$scope.exam_students.map(i=>(i.id)).includes( el.id );
      });
  }

plunker上的代码请检查请明确您的要求Kay让我更改plunker得到您的答案pIus标志将添加学生列表中的选择选项让我们先说josh被选中,然后josh不应在其他类似的添加中可用,但如果用户更改选项我认为您可以禁用该选项怎么办选项,以便只能删除它们。
 $scope.filteredstudents =angular.copy($scope.students)
  $scope.addStudent = function(name){
       $scope.exam_students.push({"id":name,"sname":name});
     debugger;
     var index = $scope.filteredstudents.findIndex(item => item.id === name);
     $scope.filteredstudents.splice(index, 1);

  }

  $scope.removeStudent = function(name){
  var examstudentindex = $scope.exam_students.findIndex(item => item.id === name);
      $scope.exam_students.splice(examstudentindex,1);
    var index = $scope.students.findIndex(item => item.id === name);
    $scope.filteredstudents.push($scope.students[index]);
  }
$scope.filterStudents = function (){
      $scope.filteredstudents = $scope.students.filter( function( el ) {
        return !$scope.exam_students.map(i=>(i.id)).includes( el.id );
      });
  }