-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUserController.js
29 lines (22 loc) · 912 Bytes
/
UserController.js
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
(function(){
var app = angular.module('githubViewer');
var UserController = function($scope, github, $routeParams) {
var onGetUser = function(data) {
$scope.gitHubUser = data;
github.getRepos($scope.gitHubUser).then(onGetRepos, onRepoError);
};
var onError = function(reason) {
$scope.error = 'Couldn\x27t load the user : ' + reason;
};
var onGetRepos = function(data) {
$scope.gitHubRepos = data;
};
var onRepoError = function(reason) {
$scope.repoError = 'Couldn\x27t get the repos : ' + reason;
};
$scope.username = $routeParams.username;
$scope.repoSortOrder = "-stargazers_count";
github.getUser($scope.username).then(onGetUser, onError)
};
app.controller('UserController', UserController)
}());