How to receive Angular data in a PHP (routed) file

1

0 vote against accept Friend, now it worked, but I was left with a doubt ... Regarding the accent, it is not accepting accentuation.

I tried the following ways, but there was no way:

var config = {         headers: {             'Content-Type': 'application / json; charset = iso-8859-1'         }     };

var config = {         headers: {             'Content-Type': 'application / json; charset = utf-8'         }     };

    
asked by anonymous 24.08.2016 / 16:18

1 answer

1

Angularjs is a client-side framework, and as you should know PHP is server-side, so it does not exist here: $ titulo = '{{libro.titulo}}'. You have to pass through $ http that value to PHP - > link $ http. Here is an example I made in an application:

$scope.salvar = function(lista)
{
    var config = {
        headers : {
            'Content-Type': 'application/json'
        }
    };

    var data = lista;

    $http.post( Url.link + 'adicionar', data, config).success(function(res){
        alert('Cadastrado com sucesso');
    });

    $scope.lista = { lis_nome: '', lis_cpf: '', lis_animal: '', lis_descricao: '' };
};

I get information from a submit of a form and submit via $ http.post.

    
25.08.2016 / 16:00