Created
February 20, 2014 05:09
-
-
Save opheliasdaisies/9107394 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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