0
I am trying to create an infinite list with Ionic/Angularjs. This list passes a offset
for my webservice page the answers from SELECT
. I’m not able to do this and I’m looking for an example but I haven’t found one yet.
I’m trying like this.
Service
var app = angular.module('starter');
app.service('EmpresaAPIService', function($http, AppConstants, HeaderFactory){
var headersJSON = HeaderFactory.getHeader.headerJSON();
this.getAllEmpresas = function(offset){
var _url = AppConstants.webServiceUrl + "/empresas/getAllEmpresas.json";
var _jsonData = {"offset": offset};
return $http.post(_url, _jsonData, {
headers: headersJSON,
});
};
});
Controller
var app = angular.module('starter');
app.controller('EmpresaCtrl', function($scope, EmpresaAPIService){
var offset = 0;
$scope.items = [];
$scope.addItems = function(){
EmpresaAPIService.getAllEmpresas(offset)
.success(function(data){
var result = data.result;
for(var x = 0; x < result.length; x++){
$scope.items.push(result[x].Empresa);
}
offset += 5;
//console.log(result[0].Empresa.nomeFantasia);
})
.error(function(err){
console.log(err);
});
};
});
Html
<ion-view title="Empresas">
<ion-content class="has-header padding">
<ion-list>
<ion-item ng-repeat="item in items track by $index">
<p>{{item.nomeFantasia}}</p>
</ion-item>
<ion-infinite-scroll on-infinite="addItems()" distance="1%"></ion-infinite-scroll>
</ion-list>
</ion-content>
</ion-view>
See one of these examples «1»«2»«3»
– Edilson