I have a JSON and it is paged. When he was not paginated, when he typed anything in the search, he would search for what was printed on the screen, as in the following example:
<form ng-submit="fechaTeclado()">
<div class="bar bar-subheader bar-light">
<label class="item item-input item-floating-label">
<i class="icon ion-search placeholder-icon"></i>
<input type="text" size="100" ng-model="q" placeholder="Procurar" type="submit" ng-submit="fechaTeclado()" ng-click="fechaTeclado()" />
<input type="submit" id="submit" value="OK" ng-click="fechaTeclado()" />
</label>
</div>
</form>
<div class="card" ng-repeat="item in ofertass | filter:q | orderBy:someModel | unique: 'cadastra_oferta_cod_oferta'" ng-init="$last ? fireEvent() : null" href="#/nhaac/ofertas_singles/{{item.cadastra_oferta_cod_oferta}}">
Now that I've paged, it keeps searching only for what's printed, already loaded into pagination.
How can I search through my JSON without having to load all records on the screen?
Follow the section of my controller with pagination:
$scope.pagination = {
limit: 8,
offset: 0
};
$scope.pagination.limit = 8;
$scope.pagination.offset = 0;
$scope.noMoreItemsAvailable = false;
$scope.ofertass = [];
$scope.getRecord = function () {
$http.get("http://meusite.com.br/admin/apis/api_listagem/lista_oferta_api.php?json=promocao" + "&latitude=" + $scope.lat_cliente + "&longitude=" + $scope.long_cliente + "&raio=" + $scope.raio + "&limit=" + $scope.pagination.limit + "&offset=" + $scope.pagination.offset).then(function (response) {
// console.log(response.data);
if (response.data.length) {
$scope.ofertass.push.apply($scope.ofertass, response.data);
$scope.pagination.offset = $scope.pagination.offset + $scope.pagination.limit;
window.localStorage.setItem("data_ofertass", JSON.stringify(response.data));
} else {
$scope.noMoreItemsAvailable = true;
if (window.localStorage.getItem("data_ofertass") === null) {
$state.go("nhaac.nachegamos");
}
}
},
function (response) {
// error message
var alertPopup = $ionicPopup.alert({
title: "error " + response.status,
template: response.statusText + "<br/>Problema: Conexão com sua Internet.",
});
}).finally(function () {
console.log("finally....");
$scope.$broadcast('scroll.infiniteScrollComplete');
});
}
$scope.doRefresh = function () {
limit = 20;
offset = 0;
$scope.noMoreItemsAvailable = false;
$scope.getRecord();
};
if (data_ofertass === null) {
data_ofertass = [];
window.localStorage.getItem("endereco_temp");
window.localStorage.getItem("endereco_atual");
};