When a user makes a selection, I want to sort and display an array in alphabetical order. Specifically, when we render data from the backend, I would like to display the fullName
in alphabetical order. The $scope.selectedControlOwner
is the ng-click
event handler that triggers when a user selects owners from the modal window and clicks Ok. This will then trigger the ng-click
event to display values on the parent window. At this point, I want to trigger the sorting function.
The
$scope.controlOwnerObj.workerName
is the ng-model that binds the values to the parent window.
Is there a 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",
}],