1.1.3 • Published 8 years ago
ng-data-source v1.1.3
ng-data-source
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" :)
1.1.3
8 years ago