-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserCtrl.js
More file actions
33 lines (23 loc) · 870 Bytes
/
UserCtrl.js
File metadata and controls
33 lines (23 loc) · 870 Bytes
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
(function() {
var app = angular.module("GithubApp");
var UserCtrl = function($scope, github, $log, $routeParams) {
var onGetUserComplete = function(data) {
$scope.user = data;
github.getRepos($scope.user)
.then(onRepos, onError);
};
var onRepos = function(data) {
$scope.repos = data;
};
var onError = function(response) {
$scope.error = "Could not fetch the user";
};
$log.info("routeParams:" + $routeParams.username);
$scope.username = $routeParams.username;
$scope.repoSortOrder = "+name";
github.getUser($scope.username).then(onGetUserComplete, onError);
};
app.controller('UserCtrl', ["$scope", "github", "$log", "$routeParams", UserCtrl]); //pass an array with the scope and http dependencies
//when used in production to make sure minifiers
// don't cause errors
})();