1.1.3 • Published 7 years ago

ng-data-source v1.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

ng-data-source

Build Status Coverage Status

A factory to help you deal with infinite loading.

usage

#controller

module.controller('myController', ['dataSource',function(dataSource){
  var model = this;
  model.dataSource = dataSource(loadItems);

  function loadItems(token){
    // token = a token returned from your service call that can be used to determinate next `page`. 
	// If it is falsey, this method will not be invoked.
    return myService.fetchItems(token);
    // should return {items:[], token:'myToken'}
  }
}]);

#html

example below uses https://github.com/sroze/ngInfiniteScroll

<div infinite-scroll="model.dataSource.load()" infinite-scroll-container="'.my-container'" infinite-scroll-distance="2">
  <my-item ng-repeat="i in model.dataSource.items" item="i"></my-item>
  <div class="infinite-scroll-loading-indicator" layout layout-align="center center">
    <md-icon md-svg-icon="ripple" ng-if="model.dataSource.loading"></md-icon>
  </div>
</div>

installation

As simple as "bower install ng-data-source" :)