Does anyone know how to select a data and go to an editing screen, using html, angularJS and php?
Example: I have a list of contacts. I want to make a button that holds the id of that contact and when I click on this button, it takes me to another html page where I can edit the contact data.
I have this:
<a href="editar.html?id={{usuario.id}}" class="btn btn-xs btn-primary">Editar</a>
And it works. I'm directed to the edit.html and with the id in the url:
localhost: 8888 / systems / websystems / Angular_CatalogJS / edit.html? id = 1
On this page I have the following code:
<script type="text/javascript">
angular.module("myCrud", []);
angular.module("myCrud").controller("myCrudCtrl", function ($scope, $http) {
var carregarUsuario = function () {
$http.get("php/buscaPEdicao.php", {params: {id: usuario}}).success(function (data){
console.log(data);
$scope.usuarios = data;
});
};
carregarUsuario();
});
</script>
</head>
<body ng-controller="myCrudCtrl">
<div class="jumbotron">
<table class="table">
<tr>
<td>Nome</td>
<td>Email</td>
<td>Password</td>
</tr>
<tr ng-repeat="usuario in usuarios">
<td><input type="text" ng-model="usuario.newName">{{usuario.name}}</td>
<td><input type="text" ng-model="usuario.newEmail">{{usuario.email}}</td>
<td><input type="text" ng-model="usuario.newPass">{{usuario.pass}}</td>
</tr>
</table>
</div>
And my php:
<?php
$id = $_POST['id'];
$usuario = mysqli_query($con, "SELECT * FROM users WHERE id='$id'");
header('Content-Type: application/json');
$return = array();
while ($dados = mysqli_fetch_assoc($usuario)) {
array_push($return, $dados);
}
echo json_encode($return);
?>