0
Guys I have an application of Ionic, however I need to do a search or filter on the contacts that appear on the screen but I’m not getting and the worst that does not return any error:
My control:
.controller('ContatosCtrl', function($scope, $timeout, $http) {
$scope.limite = 10;
$scope.contatos = [];
$scope.loadMore = function() {
$timeout(function(){
$http.get('js/dados.json').then(function(response) {
angular.forEach(response.data, function(items) {
$scope.total = items.length;
for (i=0; i < $scope.limite; i++) {
$scope.contatos.push(items[i]);
}
$scope.$broadcast('scroll.infiniteScrollComplete');
});
}, function(err) {
console.error('ERR', err);
});
$scope.limite +=10;
}, 200);
};
})
And this is my template:
<ion-view view-title="Contatos">
<ion-header-bar class="bar bar-subheader item-input-inset bar-busca bar-positive">
<div class="item-input-wrapper">
<i class="icon ion-search placeholder-icon"></i>
<input type="search" min-length="1" placeholder="Buscar" ng-model="busca.search">
<i class="icon ion-android-close placeholder-icon" ng-if="busca.search" ng-click="clearSearch()"></i>
</div>
</ion-header-bar>
<ion-content>
<ion-list>
<ion-item class="item-remove-animate item-avatar item-icon-right" ng-repeat="contato in contatos track by contato.codigo | filter:busca.search" type="item-text-wrap" href="#/tab/contatos/{{contato.codigo}}">
<img ng-src="{{contato.face}}">
<h2>{{contato.nome}}</h2>
<p>{{contato.telefone}}</p>
<i class="icon ion-chevron-right icon-accessory"></i>
</ion-item>
</ion-list>
<ion-infinite-scroll ng-if="!moredata" on-infinite="loadMore()" distance="10%"></ion-infinite-scroll>
</ion-content>
</ion-view>
I need to do a simple search filter, not sure if just adding the filter
the search would already work.
OK thanks Victor, I managed to do just as I said. After a few adjustments it was right.
– Fagnerdireito