-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainController.js
More file actions
executable file
·44 lines (31 loc) · 1.18 KB
/
mainController.js
File metadata and controls
executable file
·44 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(function () {
var app = angular.module('githubViewer'); // Use [] to first define app, []);
var mainController = function ($scope, $http, $interval, $log,
$location) {
$scope.search = function (username) {
$scope.error = '';
$scope.repos = [];
$log.log('Search');
$scope.countDownTimer = 0;
$interval.cancel(timer);
// $http.get("https://api.github.com/users/" + username)
// httpTest.getUser(username)
// set location here this function would be performed in userDetail controller
// githubmod.getUser(username)
// .then(onUserComplete, onError);
$location.path('/user/' + username);
};
var decrementCountDownTimer = function () {
$scope.countDownTimer -= 1;
if ($scope.countDownTimer < 1) {
$scope.search($scope.username);
}
};
$scope.username = "angular";
$scope.countDownTimer = 20; // set count to test the interval service
var timer = $interval(decrementCountDownTimer, 1000, $scope.countDownTimer);
console.log('Executing main controller')
};
console.log('setting up main controller');
app.controller("mainController", mainController);
}());