problem with Submit

Asked

Viewed 35 times

0

I have the following code on my form:

<div class="uk-grid">
    <div class="uk-width-1-1">
        <button type="submit" class="md-btn md-btn-primary" ng-submit="frm.$valid && Salvar(registro2)">Submit</button>
    </div>
</div>

When I click on Submit, I have the following error:

Typeerror: this. _recipeManager is null

See in the image: inserir a descrição da imagem aqui

The method Salvar is not called, someone the reason for this mistake?

Here is the beginning of my form:

<form id="frm" class="uk-form-stacked">

controller save function

  //salva ou altera registro no banco
$scope.Salvar = function (jsonTarefa) {
    $scope.progressbar.start();

    $scope.registro2.t0060_dt_agenda = document.getElementById('uk_dp_1').value;

    if ($scope.strStatus == 0)
        $scope.registro2.t0060_status = 0;

    jsonTarefa.t0031_id_pessoa = $scope.selected.t0031_id_pessoa;//seleciona o id_pessoa do select
    $http.post("/Tarefa/save", { jsonTarefa: jsonTarefa })
        .success(function (data) {
            if (data == "nosession")
                window.location.href = '#/forms/login';
            else if (data == "200") {
                $scope.getAllRegistro($scope.strPesquisa, 0);

                $scope.progressbar.complete();

                $scope.registro2 = {};
                $scope.frm.$setPristine();
                $scope.registro2.t0060_tipo = 1;
                $scope.registro2.t0060_status = 0;

            }
            else {
                UIkit.modal.alert('<div class=\'uk-text-center\'>' + data + '<br/><img id=\'img-erro\' class=\'uk-margin-top\' style=\'width: 18%;margin-bottom: -60px;\' src=\'assets/img/spinners/erro.png\' </div>', { labels: { 'Ok': 'OK' } });
                $scope.progressbar.complete();
            }
        })
        .error(function (error) {
            var str = "ERRO INESPERADO";
            $scope.sendMail(error, "Erro front end zulex");
            UIkit.modal.alert('<div class=\'uk-text-center\'>' + str + '<br/><img id=\'img-erro\' class=\'uk-margin-top\' style=\'width: 18%;margin-bottom: -60px;\' src=\'assets/img/spinners/erro.png\' </div>', { labels: { 'Ok': 'OK' } });
            $scope.progressbar.complete();
        });
};

1 answer

1

The directive ngSubmit should be set in the form, not the button, as you did. That’s why it’s not called. Your form should look like this:

<form id="frm" class="uk-form-stacked" ng-submit="frm.$valid && Salvar(registro2)">
    [...]
    <button type="submit" class="md-btn md-btn-primary">Submit</button>
</form>

That should solve your problem.

  • Celsom, the error continues, in fact the code was as you said, I did a test, and I ended up copying the wrong code. I do not know why this error.

  • @alessandremartins as is the vunção Salvar() on your controller?

  • Celsom, I edited the post and put the save function

  • @alessandremartins If at the very beginning of the function you put console.log('rodou") it displays the message in the log?

  • Celsom, did not run... I’m using the Altair template, and axo is problem with the template.

  • The form and the call as explained would be correct. It’s probably something that isn’t linking the controller to the view. Try to check this because the error refers to something that is not defined.

Show 1 more comment

Browser other questions tagged

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