I have two drop down lists containng same array elements. after selecting one element form list1(part1) the element shoulb be deleted from listB(part1). If I unselect the element in list1 then the element(part1) should be in array(list2) vice versa.
So I tried like this
Controller.js
$scope.list1= [{"columnName": "part1",value: "obj1"},
{"columnName": "part2",value: "obj2"},
{"columnName": "part3",value: "obj3"},
{"columnName": "part4",value: "obj4"},
{"columnName": "part5",value: "obj5"}]
$scope.list2 = [{"columnName": "part1",value: "obj1"},
{"columnName": "part2",value: "obj2"},
{"columnName": "part3",value: "obj3"},
{"columnName": "part4",value: "obj4"},
{"columnName": "part5",value: "obj5"}]
$scope.getColumn = function(colum) {
$scope.indexOfcolum = $scope.list2.indexOf(colum);
$scope.removecolum = $scope.list2.splice($scope.indexOfcolum,1)
console.log($scope.indexOfcolum ,'colum index',$scope.removecolum)
}
Html
<form>
Xxis <select ng-model="xcolumn" ng-options=" l1.columnName for l1 in list1"ng-change="getColumn(xcolumn)">
<option value=""></option>
</select>
yAxis
<select ng-model="xcolumn" ng-options=" l2.columnName for l2 in list2"ng-change="getColumn()">
<option value=""></option>
</select>
</form>
Here my fiddle link :http://jsfiddle.net/soumyagangamwar/9ra59ptb/
When I unselect the(option value="") then array should contain all the elements. and If I select one value in list A(part1) that should not appear in second list. and then If I select second value in listA(part2) then part2 is disappear in listB and part1 also should in listB.
can any one please help me to this