I wanted to sort and display array in alphabetical order once user make selection or when we render data from backend i want to display fullName
in alphabetical order. $scope.selecedControlOwner
is ng-click
event handler once user select owners from the modal window and click Ok ng-click
event trigger and display values on parent window Now here i want to trigger sorting.
$scope.controlOwnerObj.workerName
is ng-model that is binding the values to parent window.
Is there any solution using AngularJs or native Javascript ?
ctrl.js
$scope.selectedControlOwner = function() {
$scope.controlOwnerObj.workerName= $scope.selectedOwners.map(function (owner) { return owner.fullName; }).join(';');
};
$scope.selectedOwners = [{
"workerKey": 46958,
"fullName": ,"Kumari, Swapna"
}, {
"workerKey": 746,
"fullName": "Mike Piero",
}, {
"workerKey": 150918,
"fullName": "A J, Jyothish",
}],