I am creating a website and I am using angular, and in the only existing input the required is not working, ie even clicking on the submit button is sending the empty data to the bank, what can it be?
$scope.adicionaTopico = function (topico) {
console.log(topico.assunto);
console.log(topico.descricao);
$http({
url: URL + '/topico/cadastrar',
method: "POST",
data: {
'assunto': topico.assunto,
'idUsuario':1,
'situacao': 'ATIVO',
'datahora': new Date(),
'descricao': topico.descricao,
'grau':'1'
}
})
.then(function(response) {
$location.path('/');
},
function(response) { // optional
alert("Erro!!!" + response);
});
};
<label for="descricao" class="col-sm-1 control-label">Descrição:</label>
<div class="col-sm-9">
<input type="text" name="desc" class="form-control" id="desc" placeholder="Seja especifico" ng-model="topico.descricao" required="required">
</div>
<button type="submit" class="btn btn-info" ng-click="adicionaTopico(topico)">Criar Tópico</button>