Ionic Framework Infinite Scrolling

Ionic Framework is very friendly to use and implement, but when dealing with large dataset with ng-repeat in list item in the view, the performance becomes very poor.

To handle this problem, by appending subset of data each time to the view such as infinite scrolling will be helpful to enhance the user experience and performance.  Although I could not find any documentation in Ionic Framework Doc about infinite scrolling, there is an setting on-infinite-scroll on content directive.

If your data array is already filled in with data, one way to play with your data array in ng-repeat is combine it with filter limitTo.  By limiting your data to display, loading list on the page will be smooth.  So when scrolling down, you can change the parameter in your on-infinite-scroll function for limitTo .   

Here is an example:

See the Pen gnFyj by Sunny (@sunnycyk) on CodePen.


Read More

Ionic Framework Tab Solution

Today I was playing with Ionic Framework, and found there is small problem when using Tabs and reload the tab page that is not on the first page in the web browser.  The history stack is lost and so that the back button is disappeared.  (For example, I have a home tab, and home tab have multiple pages.  if a link on first page is clicked, then second page will appear, and back arrow button that link to the first page will appear on the header.  The history stack is keeping track by Angular. However, if refresh the browser on second page, the back arrow will not show up because all state will be gone as Angular restarted.)

Furthermore, even if I click on the Tab again, it will not bring me back to the first page and throw an error (Cannot call method querySelectorAll).

In order to avoid this happen, a small trick can be done by using Angular’s $location service in .  When the angular app is reload on your browser, $location service just make a redirection to your App’s first page.  and that’s it, so that your webapp will always start from the first page when reloaded!

For example,

angular.module(‘ionicApp’, [‘ionic’]).run(function($location) {$location.path(‘#/tab/firstpage’);});

P.S.  I think this only need to apply to Web app on web browser.  For PhoneGap App, I don’t think there is issue for this since your app will not reload from other page.

Read More