-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepoController.js
30 lines (23 loc) · 975 Bytes
/
RepoController.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
30
(function() {
var app = angular.module('githubViewer');
var RepoController = function($scope, github, $routeParams) {
var onGetRepo = function(data) {
$scope.repo = data;
github.getContributors($scope.repo).then(onGetContributors, onContributorsError);
};
var onError = function(reason) {
$scope.error = 'Couldn\x27t load the repo : ' + reason;
};
var onGetContributors = function(data) {
$scope.contributors = data;
};
var onContributorsError = function(reason) {
$scope.contributorsError = 'Couldn\x27t get the contributors : ' + reason;
};
$scope.username = $routeParams.username;
$scope.reponame = $routeParams.reponame;
$scope.contributorSortOrder = "+login";
github.getRepo($scope.username, $scope.reponame).then(onGetRepo, onError)
};
app.controller('RepoController', RepoController)
}());