I am having the requirement in AngularJS on Multi Select fields.
I have 2 multi select drop-downs and I need to pass the data between them through 3 buttons. I tried sample in JSFiddle but I was unable to succeed. Please find the details in the below link.
HTML CODE
<div ng-controller="MyCtrl"><select multiple="true" ng-model="selectedDetails" ng-options="c.name+' ('+c.id+')' for c in rule"></select>
<button ng-click='moveSelectedToRight(selectedDetails)'>></button>
<button ng-click='moveAllSelected(selectedDetails)'>>></button>
<button ng-click='moveSelectedToLeft(selectedDetails)'><</button>
<select multiple="true" ng-model="selectedDetailsCopied" ng-options="c.name+' ('+c.id+')' for c in selectedDetailsCopied"></select>
<div>
<p>Selected Details: {{selectedDetails }}</p>
<p>Copied Details: {{selectedDetailsCopied}}</p>
</div>
JS CODE
var myApp = angular.module('myApp', []);
function MyCtrl($scope) {
$scope.selectedDetails = [];
$scope.selectedDetailsCopied=[];
$scope.rule = [{
name: 'Rock',
id: '0'},
{
name: 'white',
id: '1'},
{
name: 'Test',
id: '2'},
{
name: 'Fun',
id: '3'},
{
name: 'Laaa',
id: '4'
}];
$scope.moveSelectedToRight = function(selectedDetails){
$scope.selectedDetailsCopied = angular.copy(selectedDetails);
}
$scope.moveAllSelected = function(selectedDetails){
$scope.selectedDetailsCopied = angular.copy($scope.rule);
}
$scope.moveSelectedToLeft = function(selectedDetails){
$scope.selectedDetailsCopied = [];
}
}