После нескольких часов работы с этим, я буду конкретен.
Я пытаюсь передать данные из таблицы угловых значений (представление) в контроллер, вызов контроллера на завод ипоследний делает http-запрос к .php файлу.
Это не так сложно, как кажется.
Это ошибка, которую я получаю}
Попытка получить свойство необъекта в строке 6
Это мой файл .php (чтобы получить простой запрос на выборку)
// Including database connections
require_once '../../db/database_connections.php';
// Fetching and decoding the inserted data
$data = json_decode(file_get_contents("php://input"));
$query = "SELECT * from repartidor WHERE id_repartidor = '$data->codigo'"; //THIS is **line 6**
$result = mysqli_query($con, $query);
$arr = array();
$row = mysqli_fetch_assoc($result);
$arr[0] = $row;
// Return json array containing data from the databasecon
echo $json_info = json_encode($arr[0]);
?>
Однако после отладки его дляв то время как запрос и ответ файла .php действительно работают (я доказываю, что он заменяет '$ data-> codigo' значением).
Я думаю, что проблема в том, что данные не достигают илинеправильно декодируется.
Заводской код:
obtenerItem: function(item){
return $http.post("http://localhost/sgzena/php/repartidor/repDetail.php", item);
} //THERE is an update
Код контроллера:
$scope.actualizarItem = function (item) {
repartidorFactory.obtenerItem(item) //aca iba ID
.then(function (response) {
var modal = abrirModal(response.data);
modal.result.then(function(result) {
guardarRepartidor(result);
});
});
}
Просмотр кода:
<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>Cod.</th>
<th>Nombre</th>
<th>Telefono</th>
<th>
<em class="glyphicon glyphicon-cog" tooltip-placement="top" uib-tooltip="Acciones"></em>
</th>
</tr>
</thead>
<tbody ng-repeat="item in repartidores">
<tr class="odd gradeX">
<td>{{item.id_repartidor}}</td>
<td>{{item.nombre}}</td>
<td>{{item.telefono}}</td>
<td>
<a class="btn btn-default glyphicon glyphicon-edit " tooltip-placement="bottom" uib-tooltip="Editar Repartidor" data-toggle="modal" ng-click="actualizarItem(item)"></a>
<a class="btn btn-default glyphicon glyphicon-trash " tooltip-placement="bottom" uib-tooltip="Eliminar Repartidor" ng-click="eliminarItem(item)"></a>
</td>
</tr>
</tbody>
</table>