I can not access objects within $ scope

0

I'm trying to validate a form, it only writes the data if it passes in if ($scope.frmCliente.$$invalid) , but the frmClient object is not being accessible within $ scope.

The error that appears in the console:

  

ReferenceError: yesre is not defined       at m. $ scope.cadrastarCustomers (client-controller.js: 27)       at fn (eval at compile (angular.js: 15126), 4: 242)       at b (angular.js: 16213)       at and (angular.js: 26592)       at m. $ eval (angular.js: 17994)       at m. $ apply (angular.js: 18094)       at HTMLInputElement. (angular.js: 26597)       at HTMLInputElement.dispatch (jquery.min.js: 3)       (jquery.min.js: 3) (anonymous) @ angular.js: 14199

form code

<div id="cadastro"  class="row" >
   <form name="frmClientes" novalidate ng-submit="cadrastarClientes()"  ng-if="tela == 2 || tela == 3"
      class="form-group">
      <div class="row">
         <h3 ng-if="tela == 2">Alterar Clientes</h3>
         <h3 ng-if="tela == 3">Cadastrar Clientes</h3>
      </div>
      <div  ng-if="tela == 2" class="row">
         <div class="col-md-1">
            <label>ID:</label>
         </div>
         <div class="col-md-4">
            <input  type="text" id="campoText"
               placeholder=""
               class="form-control"  value=""
               ng-model="cliente.id" ng-disabled="true" />
         </div>
      </div>
      <div class="row">
         <div class="col-md-1">
            <label>Nome:</label>
         </div>
         <div class="col-md-5">
            <input type="text" name="campoNome" placeholder="" maxlength="50" ng-minlength="2"
               class="form-control" required
               ng-model="cliente.nome" />
            <div>
               <span ng-show="frmClientes.campoNome.$error.required && frmCliente.campoNome.$dirty">Campo Obrigatorio</span>
               <span ng-show="frmClientes.campoNome.$error.minlength">Nome Ivalido, minimo 2 caracteres</span>
            </div>
         </div>
      </div>
      <div class="row">
         <div class="col-md-1">
            <label>E-mail:</label>
         </div>
         <div class="col-md-4">
            <input type="email" name="campoEmail" placeholder="[email protected]" required class="form-control" ng-model="cliente.email" />
            <span ng-show="frmClientes.campoEmail.$error.required && frmCliente.campoEmail.$dirty">Campo Obrigatorio</span>
            <span ng-show="frmClientes.campoEmail.$error.email">E-mail invalido</span>
         </div>
      </div>
      <div class="row">
         <div class="col-md-2">
            <input type="button"  class="btn btn-default" value="salvar"
               ng-click="cadrastarClientes()" />
            <input type="button"
               class="btn btn-default" value="cancelar" ng-click="cancelar()" /> 
         </div>
      </div>
   </form>
</div>

function in the controller responsible for saving

    $scope.cadrastarClientes = function() {
    console.log(yesre);
    if ($scope.frmCliente.$invalid) {
        $http({
            method: 'POST',
            url: 'http://localhost:8080/cliente',
            data: $scope.cliente
        }).then(function(response) {
            console.log(response.data);
            $scope.cliente.nome = null;
            $scope.clientes.push(response.data);
            $scope.carregarClientes();
            $scope.mensagem = false;
        }, function(response) {
            console.log(response.data);
            console.log(response.status);
        });
    } else {
        $scope.mensagem = true;

    }
};
    
asked by anonymous 29.10.2017 / 13:14

0 answers