As I tackle a specific logical challenge, I find myself struggling a bit. Here is the issue at hand:
When sending a PUT request from within a controller using certain factory methods, my aim is to update the data without triggering a page refresh. For example, using $state.go() or $location.path(). I have successfully implemented solutions for POST and DELETE requests like so:
$scope.$on('itemRemoved', (e, item) => {
vm.allItems = vm.allItems.filter(item => {
item._id !== item._id)
})
})
$scope.$on('itemAdded', (e, item) => vm.allItems.push(item))
// For PUT, I am looking to achieve something similar..
$scope.$on('itemUpdt', (e, item) => {
vm.allItems.push(item).findIndex('index of oldItem').splice('exclude oldItem index').join(',')
})
'item' represents an array of objects obtained from an AJAX call. The approach mentioned above did not yield the desired results for me. Is there a mistake in my method or are there more effective ways to address this issue? Thank you for taking the time to read :)