私のコードを掲載しました。私はオプションからKanhu
を削除したいと思います。AngularJSで動的に作成されたドロップダウンオプションを削除するにはどうすればよいですか?
実例を参照してください。ここで
var myApp = angular.module('myApp',[]);
function myCtrl ($scope) {
$scope.userProfiles = [
{id: 10, name: 'Chinmay'},
{id: 27, name: 'Sanjib'},
{id: 35, name: 'Kanhu'},
{id: 38, name: 'Pradeepta'},
{id: 39, name: 'Debsish'},
];
$scope.selectedUserProfile= $scope.userProfiles[1].id;
$scope.existingId = 35;
};
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
Name
<select id="requestorSite" ng-model="selectedUserProfile" ng-options="userProfile.id as userProfile.name for userProfile in userProfiles">
</select>
<br/>
</div>
はドロップダウンに来て5名ですが、私は私のドロップダウンオプションからkanhu
を削除したいです。それを取り除く方法を教えてもらえますか?
私はフィルタuserProfile.id as userProfile.name for userProfile in userProfiles | filter:{id: !existingId}
を使用しようとしましたが、これは動作しません。
してみてください。http://stackoverflow.com/questions/24761281/hiding-an-option-in-ng -options –