It turns out that I make this request in the controllers to my php:
$http({
method: 'POST',
url: 'http://localhost/nPanelarencion/app/php/consulta.php',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
})
which in console shows me its data in the following way
These same data I need to save them in $scope
to be able to use them in html ...
Controller code:
app.controller('search', function($timeout, $scope, $http) {
// comienza la conexion
getInfo();
function getInfo(){
$http({
method: 'POST',
url: 'http://localhost/nPanelarencion/app/php/consulta.php',
headers: {
'Content-Type': 'application/json', /*or whatever type is relevant */
'Accept': 'application/json' /* ditto */
},
data: {
/* You probably need to send some data if you plan to log in */
}
})
.success(function(data){
console.log(data);
localStorage.setItem("Tickets", angular.fromJson(data));
//NEXT>
$scope.loadUsers = function() {
return $timeout(function() {
$scope.tickets = localStorage.getItem('Tickets');
}, 650);
};
})};
conection.php:
<?php
// Connecting to database as mysqli_connect("hostname", "username", "password", "database name");
$con = mysqli_connect("localhost", "root", "", "saltala");
?>
consult.php:
<?php
// Including database connections
require_once 'conection.php';
// mysqli query to fetch all data from database
$query = "SELECT rut, numero, servicio_id FROM Tickets";
$result = mysqli_query($con, $query);
$arr = array();
if(mysqli_num_rows($result) != 0) {
while($row = mysqli_fetch_assoc($result)) {
$arr[] = $row;
}
}
// Return json array containing data from the databasecon
echo $json_info = json_encode($arr);
?>
QUESTION: How do I do it? I tried to pause it and everything but it still does not work out.
I need to show the rout in a select
<md-select placeholder="Assign to user" ng-model="buscar" md-on-open="loadUsers()" style="min-width: 200px;">
<md-option ng-value="user" ng-repeat="tick in tickets | filter : buscar" >{{tick.rut}}</md-option>
</md-select>