I have the following array:
$scope.myData = [
{id: 1, age: 50},
{id: 2, age: 43},
{id: 8, age: 27},
{id: 9, age: 29}
];
What I would like to do is to remove a row if given the row id value. I understand that I could use something like:
$scope.myData.splice(0,1);
But how can I determine the row number if for example I am given:
var idToRemove = 8;
Here is a solution I was given that uses jQuery. Unfortunately I don't use jQuery so I am looking for a javascript solution.
function remove(array, property, value) {
$.each(array, function(index, result) {
if (result[property] == value) {
array.splice(index, 1);
}
});
};