0
I have the following listing structure:
<div style="position: fixed;z-index: 999;top:20%;margin:0 auto;left:25%;width:50%;padding:5%;background:#FFF;" ng-if="templateForm == 'light-box-selectcasa'">
<div class="col-md-12">
<label>SELECIONE UMA CASA PARA LISTAR AS INFORMAÇÕES</label>
<select class="form-control" ng-options="item as item.referencia for item in casas.list track by item.id" ng-model="obj.casa"></select>
</div>
<div class="col-md-12">
<br/>
<button class="btn btn-block btn-primary" ng-click="setCasa()">SELECIONAR CASA</button>
</div>
<div style="position:fixed;width:1px;height:1px;float:left;"><img style="position:relative;float:left;right:190px;bottom:50px;" src="<?= base_url('assets/img/man-calendar.png') ?>"/></div>
</div>
The listing, is correct, lists the database items and etc.
And then I have the function inside the angular, setCasa():
var casaRef = '';
app.controller("agendaController", function ($scope, $http, $timeout) {
$scope.setCasa = function () {
casaRef = $scope.obj.casa;
$scope.template = '';
$scope.templateForm = '';
};
}
But when for the action of setCasa, if I give an Alert in casaRef, it comes only with [Object Object].
How to pass this variable so that when I give the Alert, arrive then what was selected?
Put Alert(JSON.stringify(casaRef));
– Sorack
Appeared a lot of things now rsrs
– Sr. André Baill
Is it that or do you want something different?
– Sorack
Thus it worked oh Alert(JSON.stringify(casaRef['id'])); only that even so, I do not know how to set the variable casaRef, with this id
– Sr. André Baill
So I think your ng-model is setting obj.casa with the entire array of options and not with the selected one. Probably ng-options has some problem. I will analyze it
– Sorack
This here houseRef = $Scope.obj.casa; has to be set what came from the list..
– Sr. André Baill
Let’s go continue this discussion in chat.
– Sr. André Baill