From fed9ff29a9a2390146666ec19119836fa91cd96a Mon Sep 17 00:00:00 2001 From: Mathieu Date: Sat, 28 Dec 2013 12:05:09 +0800 Subject: [PATCH] Add 3 movies in example, looks better --- examples/starters/list/js/controllers.js | 34 +++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/examples/starters/list/js/controllers.js b/examples/starters/list/js/controllers.js index ff72f71568..e620bcb6dd 100644 --- a/examples/starters/list/js/controllers.js +++ b/examples/starters/list/js/controllers.js @@ -2,7 +2,7 @@ angular.module('listExample.controllers', []) // Controller that fetches a list of data -.controller('MovieIndexCtrl', function($scope, MovieService) { +.controller('MovieIndexCtrl', function($scope, MovieService,$timeout) { // "MovieService" is a service returning mock data (services.js) // the returned data from the service is placed into this @@ -10,6 +10,38 @@ angular.module('listExample.controllers', []) $scope.movies = MovieService.all(); $scope.title = "Completely Random Collection Of Movies"; + + // Method called on infinite scroll + // Receives a "done" callback to inform the infinite scroll that we are done + $scope.loadMore = function(done) { + $timeout(function() { + $scope.movies.push({ + id: 'tt0114814', + title: 'Usual Suspects', + released: '1995', + description: 'A boat has been destroyed, criminals are dead, and the key to this mystery lies with the only survivor and his twisted, convoluted story beginning with five career crooks in a seemingly random police lineup.', + director: 'Bryan Singer', + rating: 8.3 + }); + $scope.movies.push({ + id: 'tt0357413', + title: 'Anchorman: The Legend of Ron Burgundy', + released: '2004', + description: "Ron Burgundy is San Diego's top rated newsman in the male-dominated broadcasting of the 70's, but that's all about to change for Ron and his cronies when an ambitious woman is hired as a new anchor.", + director: 'Adam McKay', + rating: 7.2 + }); + $scope.movies.push({ + id: 'tt0058331', + title: 'Mary Poppins', + released: '1964', + description: "A magic nanny comes to work for a cold banker's unhappy family.", + director: 'Robert Stevenson', + rating: 7.7 + }); + done(); + }, 1000); + } }) // Controller that shows more detailed info about a movie