I'm trying to make this work fine, but when i send a delete request it says Cannot read property '_id' of undefined, i dont know why its doesnt work, since i have another identical endpont working fine.
$http.get('/api/equipamentos').success(function(equipamentos) {
$scope.equipamentos = equipamentos;
socket.syncUpdates('equipamento', $scope.equipamentos);
});
$scope.addEquipamento = function() {
if($scope.equipamento === '') {
return;
}
$http.post('/api/equipamentos', { name: $scope.equipamento });
$scope.equipamento = '';
};
$scope.deleteEquipamento = function(equipamentos) {
$http.delete('/api/equipamentos/' + equipamentos._id);
};
$scope.$on('$destroy', function () {
socket.unsyncUpdates('equipamento');
});
Just forgot to pass the parameter to the function in the HTML code!