-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
41 lines (32 loc) · 981 Bytes
/
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
var app = angular.module("myApp", []);
// var person={
// firstName: "Sanjog",
// lastName: "Sigdel",
// imageSrc: "https://avatars3.githubusercontent.com/u/6120118?v=3"
// }
// app.controller("mainController", function($scope) {
// $scope.person = person;
// });
app.controller("serviceHandler",function($scope, $http){
var onUserComplete = function(response){
$scope.user = response.data;
$http.get($scope.user.repos_url)
.then(onRepos, onError);
};
var onRepos = function(response){
$scope.repos = response.data;
};
var onError = function(reason){
$scope.error = "Couldn't Fetch the data";
};
$scope.search= function(username){
$http.get("https://api.github.com/users/"+username)
.then(onUserComplete, onError);
};
});
// app.controller("mainCtrl", function($scope){
// $scope.message="Helo Angular";
// $scope.firstName= firstName;
// $scope.lastName= lastName;
// $scope.imageSrc= imageSrc;
// });