I have a $rootScope object in AngularJS like this:
$rootScope.stuff = {
someId: {
name: "Patrick",
age: 105
},
anotherId: {
name: "Joseph",
age: 94
}
};
I have a function defined that adds objects to $rootScope.stuff, and it works fine:
$rootScope.addSomeStuff = function(id, data) {
$rootScope.stuff[id] = data;
};
However, I also have a function that tries to delete (based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete), and it is not working:
$rootScope.deleteStuff = function(id) {
delete $rootScope.stuff[id];
};
When I check $rootScope.stuff[id]
I am getting the correct object that I want to delete. I have also tried splice, but that throws an error like I thought it would. Any suggestions? Thanks.