I'm pretty new to angular and I'm kind of stuck with an issue. I have a sample example of my problem jsfiddle
function HelloCntl($scope) {
$scope.selectname1={};
$scope.selectname2={};
$scope.selectname3={};
$scope.filter1 = function(item){
return (!($scope.selectname1&&$scope.selectname1.id)||item.id !=$scope.selectname1.id);
};
$scope.filter2 = function(item){
return (!($scope.selectname2&&$scope.selectname2.id)||item.id!=$scope.selectname2.id);
};
$scope.filter3 = function(item){
return (!($scope.selectname3&&$scope.selectname3.id)||item.id !=$scope.selectname3.id);
};
$scope.friends = [
{
id:1,name: 'John'},
{
id:2,name: 'Mary'},
{
id:3,name: 'Mike'},
{
id:4,name: 'Adam'},
{
id:5,name: 'Julie'}
];
}
<div ng:app>
<div ng-controller="HelloCntl">
<ul>
<li ng-repeat="friend in friends | filter:{name:'!Adam'}">
<span>{{friend.name}}</span>
</li>
</ul>
<select ng-model="selectname1"
ng-options="item as item.name for item in friends|filter:filter2|filter:filter3" ><option value="">- select - </option></select>
<div>{{selectname1}}</div>
<select ng-model="selectname2"
ng-options="item as item.name for item in friends|filter:filter1|filter:filter3" ><option value="">- select -</option></select>
<div>{{selectname2}}</div>
<select ng-model="selectname3" ng-options="item as item.name for item in friends|filter:filter1|filter:filter2" ><option value="">- select -</option></select>
<div>{{selectname3}}</div>
</div>
</div>
I am trying to implement this code in a single drop down menu, rather than 3 menus. With each click showing the selected option.
The overall functionality I am trying is creating a dropdown menu with items. These items when selected will print their names below with a delete button. Upon selecting an item, it should be automatically removed from the dropdown so that it can't be used further. And adding another item should be possible further below (append)
Unfortunately I can't seem to figure out how to get this to work. Can anyone help me out with this ?