I have created an employee form that allows users to add, search for, and delete employee details. Within the controller, I have separate functions for these operations. After adding or deleting an employee, I want the result list to update dynamically (showing added employees but not deleted ones). How can I achieve this? Should I call the search function again after a successful delete operation, or is there another way to accomplish this? My technology stack includes Angular JS and Spring MVC.
This is the Controller Code for the Search:
$http.post('http://localhost:8080/services/employee/search/'+Systems+"", searchCriteria)
.then(function(response) {
$scope.searchresponse= [];
$scope.searchresponse = response.data.items;
if (response.data && response.data.items.length != 0) {
$scope.searchresponse = response.data.items.map(function (x) {
x.selected = false;
return x;
});
console.log($scope.searchresponse);
}
else {
$scope.showerror = true;
$scope.ErrorMsg ="There is no record matching your criteria."
}
});
This is the Search Response From API:
{
"items": [{
"employeeId": "ABC",
"type": "D",
"alive": "Yes"
}, {
"employeeId": "DEF",
"type": "A",
"alive": "Yes"
}],
"more": false
}
This is the Controller call for Delete:
var data1=["ABC", "NPK"];
$http.delete('http://localhost:8080/services/employee/delete/'+Systems+"", {data:{"idList":data1},headers: {'Content-Type': 'application/json'}} )
.then(function(response) {
console.log("testing");
// - here i would like to implement code to remove all the fields that belong to eomployee id ABC,NPK from result page
});
I am utilizing selectall/deselect all checkboxes to provide users with the option to remove multiple items.