UNPKG

angular-material-npfixed

Version:

The Angular Material project is an implementation of Material Design in Angular.js. This project provides a set of reusable, well-tested, and accessible Material Design UI components. Angular Material is supported internally at Google by the Angular.js, M

48 lines (39 loc) 1.41 kB
(function () { 'use strict'; angular .module('virtualRepeatInfiniteScrollDemo', ['ngMaterial']) .controller('AppCtrl', function($timeout) { // In this example, we set up our model using a plain object. // Using a class works too. All that matters is that we implement // getItemAtIndex and getLength. this.infiniteItems = { numLoaded_: 0, toLoad_: 0, // Required. getItemAtIndex: function(index) { if (index > this.numLoaded_) { this.fetchMoreItems_(index); return null; } return index; }, // Required. // For infinite scroll behavior, we always return a slightly higher // number than the previously loaded items. getLength: function() { return this.numLoaded_ + 5; }, fetchMoreItems_: function(index) { // For demo purposes, we simulate loading more items with a timed // promise. In real code, this function would likely contain an // $http request. if (this.toLoad_ < index) { this.toLoad_ += 20; $timeout(angular.noop, 300).then(angular.bind(this, function() { this.numLoaded_ = this.toLoad_; })); } } }; }); })();