Hello
I have the following controller in the angle:
myApp.controller('cadastrarClienteController', function($scope, $http){
$scope.cadastrarCliente = function () {
$cliente = {
CliNome: $scope.cli_nome,
CliTelefone: $scope.cli_telefone,
CliEmail: $scope.cli_email,
CliDescricao: $scope.cli_descricao
};
var response = $http({
method: "post",
url: baseUrl + "/index.php/Clientes/create",
data: JSON.stringify($cliente),
dataType: "json"
});
return response;});
Is the correct way I'm working?
create no php
public function create() {
if ($this->method == 'POST') {
$var = json_decode($_POST['cliente']);
var_dump($var);
/*$nome = $this->input->post('cli_nome');
$descricao = $this->input->post('cli_descricao');
$telefone = $this->input->post('cli_telefone');
$email = $this->input->post('cli_email');
$data = array(
'cli_nome' => $nome,
'cli_descricao' => $descricao,
'cli_telefone' => $telefone,
'cli_email' => $email,
);
$res = $this->clientes_model->create_cliente($data);*/
}
}
I do not know what exactly to do within that if
. That is, how to "catch" the data that comes from POST
sent by angular
.
Is it in response
that returns that worked?
Thank you