I'm trying to create an action that deletes a oject from the database and the object array it belongs to, but for some reason, it deletes all of the scope objects of that particular array instead of the one it's supposed to. Below is the system I have.
fact.add_delete = function(scope, func, db, hasCollection, collection, redirect) {
scope.finish = null;
scope[func] = function(id) {
var query = 'DELETE FROM `' + db + '` WHERE id=' + id + '';
var obj = scope[db].filter(function(value) {
return (value.id == id)
});
$http.post('php/adb/update.php', {
'query': query
}).success(function(data) {
console.log('Deleted from [' + db + '] at id of ' + id + '');
scope[db].splice(obj);
if (hasCollection) {
scope[collection].splice(obj);
}
fact.load(scope);
scope._finish = true;
});
};
};
it works for objects within an ngRepeat but not for parent-like objects. Any reason as to why?