function ($scope, $http) {
$scope.selectFaIndex = 0;
$scope.SelectedAvailItems = [];
$scope.SelectedSelectedListItems = [];
$scope.DefaultListItems = [
[]
];
$scope.SelectedListItems = [
[]
];
$scope.AvailableListItems = [
[]
];
AllListofMainDivisionDesignation();
function AllListofMainDivisionDesignation() {
$http.get("MainDivisionDesignationMap/AllListofMainDivisionDesignation").then(function (t) {
$scope.List = t.data;
var inputObj = t.data;
angular.forEach(inputObj, function (value, key) {
this.DefaultListItems.push(key.DesignationName + ':' + value.DesignationName);
}, $scope.DefaultListItems[$scope.selectFaIndex]);
});
}
angular.copy($scope.DefaultListItems, $scope.AvailableListItems);
alert($scope.AvailableListItems);
$scope.btnRight = function () {
angular.forEach($scope.SelectedAvailItems, function (value, key) {
this.push(value);
}, $scope.SelectedListItems[$scope.selectFaIndex]);
//remove the ones that were moved.
angular.forEach($scope.SelectedAvailItems, function (value, key) {
for (var i = $scope.AvailableListItems[$scope.selectFaIndex].length - 1; i >= 0; i--) {
if ($scope.AvailableListItems[$scope.selectFaIndex][i].DesignationName === value.DesignationName) {
$scope.AvailableListItems[$scope.selectFaIndex].splice(i, 1);
}
}
});
$scope.SelectedAvailItems = [];
};
$scope.btnLeft = function () {
//move selected.
angular.forEach($scope.SelectedSelectedListItems, function (value, key) {
this.push(value);
}, $scope.AvailableListItems[$scope.selectFaIndex]);
//remove the ones that were moved from the source container.
angular.forEach($scope.SelectedSelectedListItems, function (value, key) {
for (var i = $scope.SelectedListItems[$scope.selectFaIndex].length - 1; i >= 0; i--) {
if ($scope.SelectedListItems[$scope.selectFaIndex][i].DesignationName === value.DesignationName) {
$scope.SelectedListItems[$scope.selectFaIndex].splice(i, 1);
}
}
});
$scope.SelectedSelectedListItems = [];
};
});
});
Laxmidhar SahooRank #383 · 6.6K reputationPosted Dec 5, 2017, 8:19 PM EST
BKS Saha41 reputationPosted Dec 5, 2017, 8:42 PM EST
Laxmidhar SahooRank #383 · 6.6K reputationPosted Dec 5, 2017, 8:53 PM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts