Skip to content

Instantly share code, notes, and snippets.

@opheliasdaisies
Created February 20, 2014 05:09
Show Gist options
  • Save opheliasdaisies/9107394 to your computer and use it in GitHub Desktop.
Save opheliasdaisies/9107394 to your computer and use it in GitHub Desktop.
"use strict";
var lifeControllers = angular.module("lifeControllers", []);
lifeApp.controller("BoardCtrl", ["$scope", "$http", "$timeout",
function($scope, $http, $timeout){
$http.get("/random_board").success(function(data){
$scope.boards = data;
var loading = false;
var nextMove = function(){
$scope.boards.shift();
$timeout(nextMove, 1000);
if ($scope.boards.length < 20 && loading == false){
loading = true;
$http.get("/tick_board").success(function(data){
$scope.boards = $scope.boards.concat(data);
loading = false;
});
}
}
nextMove();
});
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment