0
I have a mobile app I have a form
that makes a filter by districts and municipalities what happens and that is not to rescue the selected data at home select
the button pressed or doing anything.
Controller
.controller('FiltraEstabelecimentos', function($scope, $http, $stateParams) {
$scope.BtnFiltraCat= function (campo){
$http.post("https://www.sabeonde.pt/api/api_filtra_estabelecimentos.php?distrito=" + campo.distrito + "&concelho=" + campo.concelho + "&categoria=" +$stateParams.catSlug).success(function (data) {
$scope.filtra_estabelecimentos = data;
});
};
})
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-model="campo.distrito">
<option ng-repeat="lista_distritos in distritos" value="{{lista_distritos.id}}">{{lista_distritos.titulo}}</option>
</select>
</label>
<label ng-controller="ListaConcelhos" style="border-radius: 10px;" class="item item-input item-select">
<div class="input-label">
Concelho
</div>
<select style="border-radius: 10px;" ng-model="campo.concelho">
<option ng-repeat="lista_concelhos in concelhos" value="{{lista_concelhos.titulo}}">{{lista_concelhos.titulo}}</option>
</select>
</label>
</div>
</div>
<div style="margin:0px 10px 0px 10px;">
<button type="submit" ng-click="BtnFiltraCat(campo);" 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>
Could make a
console.log(data)
and post the displayed object?data
in question contains in one of the attributes the result of the request.– Ricardo Rodrigues de Faria
If you take the fields that you select and leave only the category with you the button works and I can save the category if you have them there the button does not work
– César Sousa
Is not happening
$scope
as a parameter in the method,$scope
belongs to the controller.– Ivan Ferrer
So as I do ?
– César Sousa
Scope is this controller.
– Ivan Ferrer
Yes, but then how I do I don’t understand
– César Sousa
just remove it from the controller parameter and see if it worked.
– Ivan Ferrer
Removed looked like this
BtnFiltraCat= function (campo){ }
and it doesn’t work– César Sousa
You do not need to remove the $Scope. variable from your method
$scope.BtnFiltraCat = function(){ ... }
. You can even run Scope on the controller, but I don’t think you need to. But the problem is that you have to get $Scope.campo.district in your controller.– Ivan Ferrer
I’ll give you an answer, and then you test, blz.
– Ivan Ferrer
okay I wait
– César Sousa
I posted it there, see if it rolled.
– Ivan Ferrer
I tested but did not list either the districts or the counties
– César Sousa