→ $scope.items = [];
→ dados = $('#meu_form').serialize();
I would like to know: how to send / receive / read the above arrays to a page in PHP?
JavaScript:
app = angular.module("app",[]);
app.controller("controlador", ["$scope", "$http",
function($scope, $http){
$scope.items = [];
$scope.submitForm = function() {
var dados = $('#meu_form').serialize();
$http({
method : 'POST',
url : 'pagina.php',
data :
headers : {'Content-Type': 'application/x-www-form-urlencoded'}
})
};
page.php
$dados = json_decode(file_get_contents('php://input'), true);
foreach ($dados as $key => &$value) {
$codigo = $value['codigo'];
$quantidade = (float)$value['quantidade'];
$v_total = $value['v_total'];
}
$nome = $_POST['nome'];
$email = $_POST['email'];