I'm trying to make a method to delete a record from the database and the following message looks like in the console:
GET
>
I'm using ui-router's angular.
Here are my codes:
html:
<table width="200">
<tr>
<td><b>País</b></td>
<td><b>Sala</b></td>
</tr>
<tr ng-repeat="pais in paises">
<td>{{pais.nome}}</td>
<td>{{pais.sala}}</td>
<td><a ui-sref="editarPais({idPais: pais.idPais})">[ ]</a></td>
<td><a ng-click="apagarPais(pais.idPais)">[x]</a></td>
</tr>
</table>
Angular:
app.controller("PaisesController", function ($scope, $http, $stateParams, $state) {
$scope.apagarPais = function (pais) {
console.log("id "+pais);
$http.get("admin/php/apagaPais.php?idPais="+pais)
.success(function (data, status){
console.log(data);
carregaPaises();
});
};
carregaPaises();
});
php:
include_once("conexao.php");
$pdo = conectar();
$id = $_POST['idPais'];
print_r($id);
$apagaPais=$pdo->prepare("DELETE FROM paises WHERE idPais=:id");
$apagaPais->bindValue(":id", $id);
$apagaPais->execute();