Some context: I have a task list using an api to save each task to mysql.
My delete method is triggered by a button with ng-click (ng-click="remove(todo, $index)") and looks like this:
$scope.remove = function (todo, index) {
$http({
method: 'DELETE',
url: 'http://api.dev/api/task/delete/' + todo.id }).then(function (response) {
$scope.todos.splice(index, 1);
});
};
This works just fine, but I'm wondering how could I make it work without passing the todo and using only the index?
idusing theindex?