-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
46 lines (33 loc) · 1.33 KB
/
script.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(function(angular) {
'use strict';
var module = angular.module("myApp", []);
module.controller("MainController", ['$scope', function($scope){
var person = {
nome: "Guina",
sobrenome: "Costa",
idade: 24,
foto: "https://nerdsondotcom.files.wordpress.com/2013/03/yeoman-logo.png"
};
$scope.message = "Hello Guina";
$scope.person = person;
}]);
module.controller("HttpController", ['$scope', '$http', function($scope, $http){
var authCode = '?client_id=guinacosta&client_secret=coxas123ha';
var onUserComplete = function (response) {
$scope.user = response.data;
$http.get($scope.user.repos_url + authCode)
.then(onRepos, onError);
}
var onError = function (reason) {
$scope.errorMessage = "Deu ruim pra buscar os dados... :(";
}
var onRepos = function(response){
$scope.respositorios = response.data;
}
$scope.buscar = function(username) {
$http.get("https://api.github.com/users/" + username + authCode)
.then(onUserComplete, onError);
}
$scope.repoSortOrder = "+language";
}]);
}(window.angular));