wemersonrv

AngularJS - Ajuste dos Headers

Oct 1st, 2013
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.factory('crudService', function($http){
  2.  
  3.     var crudService = {
  4.         createNew: function(data){
  5.             console.log(data);
  6.             /*
  7.  
  8.             {
  9.                 nome: "Fulano de Tal",
  10.                 documento: "123456",
  11.                 telefone: "64 1111-2222",
  12.                 tipo: {
  13.                     documento: "000.000.000-00",
  14.                     pessoa: "F"
  15.                 }
  16.             }
  17.  
  18.             // Pessoa pode ser Fisica/Juridica (F/J)
  19.  
  20.             */
  21.  
  22.             return $http({
  23.                 url: "http://localhost/rest/crud/create",
  24.                 data : data,
  25.                 method : 'POST',
  26.                 headers : {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'}
  27.             }).then(function (response) {
  28.                 return response.data;
  29.             });
  30.         }
  31.     };
  32.  
  33.     return crudService;
  34. });
Advertisement
Add Comment
Please, Sign In to add comment