Recording Null Angularjs Database

Asked

Viewed 31 times

0

Someone can tell me what is wrong, because it is recording in the bank an empty line and a line with the form data.

$scope.submit = function () {
        var formData = {
            'clienteCNPJ': $scope.clienteCNPJ,
            'clienteRazao': $scope.clienteRazao,
            'clienteEnd': $scope.clienteRazao,
            'clienteNR': $scope.clienteNR,
            'clienteBairro': $scope.clienteBairro,
            'clienteCidade': $scope.clienteCidade,
            'clienteUF': $scope.clienteUF,
            'clienteNome': $scope.clienteNome,
            'clienteEmail': $scope.clienteEmail,
            'clienteFone': $scope.clienteFone
        };

        var request = $http({
            method: "POST",
            url: "app/models/queroContratar.php",
            data: formData
        });
        request.then(function (data) {
            console.log(data);
        })
    };
<form method="post" name="formVenda" id="formVenda" action="app/models/queroContratar.php"
                              class="needs-validation" ng-submit="submit()"
                              novalidate="">
                            <div class="row">
                                <div class="form-group col-md-4 input-group-sm">
                                    <label for="clienteCNPJ" class="col-form-label">Informe seu CNPJ:</label>
                                    <input type="text" name="clienteCNPJ" class="form-control"
                                           id="clienteCNPJ" ng-blur="pegaCNPJCompra()" ng-model="clienteCNPJ"
                                           onkeypress="mascaraMutuario(this, Cnpj)"
                                           onBlur="validar(this);" maxlength="18" autofocus>
                                    <div class="invalid-feedback font14" id="valida">
                                        Ops! Informe um <b>CNPJ válido</b>.
                                    </div>
                                </div>
                            </div>
                            <input type="hidden" name="clienteRazao" value="{{valor.data.nome}}" ng-model="clienteRazao">
                            <input type="hidden" name="clienteCidade"
                                   value="{{valor.data.municipio}}" ng-model="clienteCidade">
                            <input type="hidden" name="clienteEnd" value="{{valor.data.logradouro}}" ng-model="clienteEnd">
                            <input type="hidden" name="clienteNR" value="{{valor.data.numero}}" ng-model="clienteNR">
                            <input type="hidden" name="clienteBairro" value="{{valor.data.bairro}}" ng-model="clienteBairro">
                            <input type="hidden" name="clienteUF" value="{{valor.data.uf}}" ng-model="clienteUF">
                            <div class="row">
                                <div class="form-group col-md-4 input-group-sm">
                                    <label for="clienteNome" class="col-form-label">Seu Nome:</label>
                                    <input type="text" name="clienteNome" class="form-control text-capitalize"
                                           id="clienteNome" ng-model="clienteNome">
                                </div>
                                <div class="form-group form-check col-md-5 input-group-sm">
                                    <label for="clienteEmail" class="col-form-label">Seu Email:</label>
                                    <input type="text" name="clienteEmail" class="form-control text-lowercase" ng-model="clienteEmail"
                                           id="clienteEmail" ng-init="validaEmailCompra()">
                                    <div class="invalid-feedback font14" id="invalid">
                                        Informe um e-mail válido.
                                    </div>
                                </div>
                                <div class="form-group col-md-3 input-group-sm">
                                    <label for="clienteTel" class="col-form-label">Seu Telefone:</label>
                                    <input type="text" name="clienteFone" class="form-control celular" ng-model="clienteFone"
                                           id="clienteTel" ng-init="maskTel()">
                                </div>
                            </div>
                            <div class="card mt-3">
                                <table class="table table-sm mb-0">
                                    <thead style="background: rgba(254,187,112,.4); color: #2d1b53">
                                    <tr>
                                        <th>Operadora</th>
                                        <th class="text-center">GB</th>
                                        <th class="text-center">R$ Unit</th>
                                        <th class="text-center">Qtd</th>
                                        <th class="text-center">Total</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr ng-repeat="it in item">
                                        <td><input type="text" name="prodOp"
                                                   class="form-control form-control-sm border-0 bg-white" readonly
                                                   value="{{it.produtoOperadora}}"></td>
                                        <td><input type="text" name="prodGB"
                                                   class="form-control form-control-sm border-0 text-center bg-white"
                                                   readonly value="{{it.produtoGB}}"></td>
                                        <td><input type="text" name="prodPreco"
                                                   class="form-control form-control-sm border-0 text-center bg-white"
                                                   value="{{it.produtoPreco | currency}}"></td>
                                        <td><input type="text" name="prodQtd"
                                                   class="form-control form-control-sm border-0 text-center bg-white"
                                                   value="{{it.produtoQtd}}"></td>
                                        <td><input type="text" name="prodTotal"
                                                   class="form-control form-control-sm border-0 bg-white text-right"
                                                   value="{{it.produtoQtd * it.produtoPreco | currency}}"></td>
                                    </tr>
                                    <tr>
                                        <td colspan="5" class="text-right font20 font-weight-bold">Total: {{soma |
                                            currency}}
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="modal-footer mt-5">
                                <button type="submit" name="envia" class="btn btn-danger btn-sm" id="btnCad" disabled
                                        ng-init="disButtonCompra()">
                                    <i class="fa fa-envelope"></i>&nbsp; Enviar Solicitação
                                </button>
                            </div>
                        </form>

1 answer

0


All the action of sending the data is in Angularjs, you did it using the Submit() function. Thus, the < form > does not need a action. Try removing the action="app/models/queroContract.php" of < form >

Browser other questions tagged

You are not signed in. Login or sign up in order to post.