I'm trying to return a list from a Java webservice, but in the HTML page it goes blank, I can not see my error, below the code.
@Path("/contatos")
public class ContatoResource {
static private Map<Integer, Contato> contatosMap;
static {
contatosMap = new HashMap<Integer, Contato>();
Contato b1 = new Contato();
b1.setId(1);
b1.setNome("Rodrigo");
b1.setFone("9999-9999");
contatosMap.put(b1.getId(), b1);
Contato b2 = new Contato();
b2.setId(2);
b2.setNome("Ana");
b2.setFone("8888-8888");
contatosMap.put(b2.getId(), b2);
}
@GET
@Produces("application/json")
public List<Contato> getContatos() {
return new ArrayList<Contato>(contatosMap.values());
}
var app = angular.module("listaTelefonica", []);
app.controller("listaTelefonicaCtrl", function($scope,$http){
$scope.titulo = "Lista Telefônica";
$scope.contatos=[];
$scope.operadoras=["oi","tim","vivo","claro"]
$scope.adicionarContato=function(contato){
$scope.contatos.push(angular.copy(contato));
delete $scope.contato;
}
$scope.carregarContato = function () {
$http.get("http://localhost:8080/AngularJS/rest/contatos").success(function (data) {
$scope.contatos = data;
});
};
$scope.carregarContato();
})
<table class="table table-striped table-hover" ng-show="contatos.length>0">
<tr>
<th></th>
<th>Nome</th>
<th>Telefone</th>
<th>Operadoras</th>
</tr>
<tr ng-repeat="contato in contatos" ng-class="{selecionado:contato.selecionado}">
<td><input type="checkBox" ng-model="contato.selecionado" /></td>
<td>{{contato.nome | uppercase}}</td>
<td>{{contato.fone}}</td>
<td>{{contato.operadora}}</td>
</tr>
</table>