0
Good night,
I have two select option
the first I have a ng-change
that filters by php the data that will be shown in the second select
what happens and that it filters well through the browser console I can see that it filters well returns the JSON
filtered on does not show the options in select how I can fix it ?
View
<div ng-controller="FiltraEstabelecimentos">
<form>
<div class="row">
<div class="col">
<label ng-controller="ListaDistritos" style="border-radius: 10px; margin: 0px 0px 10px 0px;" class="item item-input item-select">
<div class="input-label">
Distrito
</div>
<select ng-controller="ListaConcelhos" ng-model="distrito" ng-options="lista_distritos as lista_distritos.titulo for lista_distritos in distritos" ng-change="id_distrito()"></select>
</label>
<label ng-controller="ListaConcelhos" style="border-radius: 10px;" class="item item-input item-select">
<div class="input-label">
Concelho
</div>
<select ng-model="concelho" ng-options="lista_concelhos as lista_concelhos.titulo for lista_concelhos in concelhos"></select>
</label>
</div>
</div>
<div style="margin:0px 10px 0px 10px;">
<button type="submit" ng-click="filtra_estabelecimentos()" style="background-color: #CA5B60; border:#CA5B60; border-radius: 10px;" class="button button-block button-positive">
<i class="ion-search"></i> Pesquisar
</button>
</div>
</form>
</div>
Controllers
.controller('ListaDistritos', function($scope, $http) {
$http.get("https://www.sabeonde.pt/api/api_distritos.php").success(function (data) {
$scope.distritos = data;
});
})
.controller('ListaConcelhos', function($scope, $http, $stateParams) {
$scope.id_distrito= function (){
$http.get("https://www.sabeonde.pt/api/api_concelhos.php?id_distrito="+$scope.distrito.id).success(function (data) {
$scope.$watch('data', function(newValue, oldValue) {
console.log(newValue);
$scope.concelhos = newValue;
});
});
};
})
I tried the first way but it does not work the second I did not understand very well can give an example with the code I have as it would ?
– César Sousa
I tried here the second way but do not show the options can see I edit the question see if this well or if something is missing now in the view
– César Sousa
I updated the example to make it clearer.
– Carlos Lemos
The second option worked right for me
– César Sousa