I am having an employee form where the user can add the employee details,search for employee details and delete those details . I have written separate functions for add,search and delete operations inside the controller . Whenever the user adds an employee / deletes an employee . I want the result list to be updated dynamically (Added employee should be shown on result list, deleted employee should not be shown on result list ). How can I achieve this . for example after the delete operation response is successful , should I call the search function again ? .Is there any other way to do these . I am using Angular JS and Spring MVC
This is my Controller Code for 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 my search Response From API
{
"items": [{
"employeeId": "ABC",
"type": "D",
"alive": "Yes"
}, {
"employeeId": "DEF",
"type": "A",
"alive": "Yes"
}],
"more": false
}
This is my 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 using selectall/deselect all checkbox to give user option to remove multiple items