3
I need to go through an element select
on a page HTML
placing the elements option
within it. I can already do that, the problem is that in the attribute value
of those option
should receive the identifiers coming from the database, but other numbers are appearing other than the value of the records and when the form is sent occurs persistence error in the Java
because the identifier does not exist to make the foreign key interface.
HTML:
<div class="input-group">
<select name="objeto.oid" id="objetoSelect"
ng-init="carregarObjeto()" ng-model="objeto"
class="form-control"
placeholder="<spring:message code="label.objeto" />"
aria-describedby="basic-addon1"
ng-options="objeto.oid as objeto.descricao for objeto in list.objetos">
</select>
<span class="input-group-addon" id="basic-addon1">
<span class="glyphicon glyphicon-pencil"></span>
</span>
</div>
Javascript:
$scope.carregarObjetos = function() {
$http({
method : "GET",
url : '<c:url value="/cadastros/objeto/getObjetos" />'
}).then(function mySuccess(response) {
var length = response.data.length;
var data = response.data;
for (var i = 0; i < length; i++) {
$scope.list.objetos.push({
oid : data[i].oid,
descricao : data[i].descricao.toString(),
label : data[i].modelo.label.toString()
});
}
}), function myError(response) {
alert("Não foi possível carregar lista de objetos");
}
}
Upshot:
Instead of showing the numbers 3
and 5
both of us options
which comes from the database table, is showing this way:
And the data is correctly received on AJAX
.
EDIT
Appears a option
thus within the select
when updating with the method carregarObjetos
:
<option value="? number:5 ?"></option>
java or javascript?
– Lollipop