Lazy loading list item using Json data with ion-infinite-scroll

I want to Lazy load a list view, similar to with ion-infinite-scroll. But i require my data to be fetched from Json file locally please help me out…

Thanking you in anticipation of a favorable reply…

at the beginning send a $http.get request to your json-file -> you get the content as the response

but then you do not nit lazy loading, because lazy loading only makes sense, if you have an API that can limit data (like a pager -> “please api get me 10 entries and skip the first 10”)

If you load data from a json file you can only load the whole bunch of data.
So load the whole data and use the ionic collection-repeat to not flooding the dom with nodes.


1 Like

Thanks bengtler,
But I can’t make use of ‘ionic collection-repeat’ because my list item consists of text elements that have varying lengths One item might have 20 characters leading it to have one height, the other item might have 8 characters, giving it a smaller height. In this scenario, collection-repeat is not useable…(Calcultate collection item height of collection repeat)…

So i’m using ion-infinite-scroll…Can you please suggest me API that can limit JSON data and load using ion-infinite-scroll…

If you have custom data, you have to write an own one.
Set up with nodejs, php, perl or anything else.

If your data is fixed you could also use sqlite plugin of cordova -> then you could store the data in an sqlite table on the phone and sending sql statements to get the correct items.

If you have generic data you need a database on a server/webspace where your data is stored.

Or you can unify your texthandling -> a listentry has a height of 40px = 255 chars -> cut off longer texts.
For longer lists and the user experience (usability) the usage of different items heights are very bad.

Our minds and eyes are looking for symmetry ^^ -> lists where the entries have different heights (without a scheme like every second entry is smaller or something like that) it is painful ^^.
So you could care a lot of time for creating databases, apis and so on.

For example -> show preview text in your list entries and with a click you can see a detail view or the fulltext in a modal.

Greets, bengtler