0
My controller is like this:
app.controller("listaTelefonicaController", function ($scope, $http)
Inside it is my adding function
ctrl.adicionarContatos = function (contato) {
            contato.telefone = ctrl.formatCel(contato.telefone);
            console.log(contato);
            var data = JSON.stringify(contato);
            $http.post("/contatos.json", {cont: data},{headers: {'Content-Type': 'application/json'}}).then(
                 function (response) {
                     console.log("success:" + response);
                     delete ctrl.contato;
                     $scope.contatoForm.$setPristine();
                     return response;
                 },
                 function (response) {
                     console.log(response);
                     return response;
                 }
             );
            // $http({
            //         url: 'http://127.0.0.1:5500/contatos.json',
            //         method: "POST",
            //         headers: {
            //             'Content-Type': 'application/json',
            //             'Accept': 'application/json'
            //         },
            //         data: contato
            //     })
            //     .then(function (response) {
            //             console.log("success:" + response);
            //         },
            //         function (response) { // optional
            //             console.log("Fail:" + response.data);
            //         });
            };
I spent a few hours searching and testing in various ways and all appeared the same mistake:
POST http://127.0.0.1:5500/contacts.json 405 (Method Not Allowed)
This file is populated with some data like this below:
{
    "nome": "Larissa",
    "telefone": "9999-3399",
    "cor": "orange",
    "data": "2015-04-12T12:53:46.204Z",
    "operadora": {
        "nome": "GVT",
        "codigo": 25,
        "categoria": "Fixo"
    }
}
The GET it all worked out, but when I try to do with the POST He gives this mistake, I’ve spent a few hours searching and I can’t find a way to solve my problem.
Directly enters the POST error option.
Last time I checked, Angular didn’t need
var data = JSON.stringify(contato);. Angular by default already does this (and with header application/json)– Wallace Maxters
I did it to try to solve the problem, but even without it does not work
– Eduardo Bobato