-2
I have a form that sends a value (CPF) of a page to be checked for existence in the database. Use an angular controller to send Cpf to service and then to Java(controller).
I’d have some example of how to do that ?
HTML code
</head>
<body>
<form method="POST">
<div class="form-group">
<label for="cpf" class="">CPF:</label>
<input type="text" name="cpf" ng-model="cpf" >
</div>
<button ng-click="buscarCliente()">Buscar Cliente</button>
</form>
</body>
</html>
Controller Code
angular.module('').controller('TesteController', function ($scope, $timeout, MensagemFactory, ) {
var vm = $scope;
vm.buscarCliente = function(){
if (vm.cpf != NULL) {
alert("!");
}
};
}
Services code
angular.module('').service('Service', function (servers) {
var service = {
getCpf: getCpf
};
function getCpf(){
return $http.get(servers.vendas + 'api/buscarCliente');
}
return service;
});
Please rewrite your question, paying attention to Portuguese errors and concordance.
– Murillo Goulart
What code do you already have ?
– Hugo Lima
https://jsfiddle.net/alexjosesilva/d48syn5c/
– alexjosesilva
In this series of video lessons of Diogo Godoi he develops a Javaee application with Angularjs explaining step by step communication between client and server. CRUD complete with communication also with data flock, very good in series, strongly recommend. https://www.youtube.com/playlist?list=PL1NdiP2jsLnuEqNkOF7-ISTciRrKd51Hv
– Breno Gomes