Created
July 17, 2016 23:08
-
-
Save bolenton/1d6925c54b58d2d548ebae8ccfb41e4f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var app = angular.module("ngApp", []); | |
var MainController = 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 = "Could not find a user" | |
} | |
$scope.search = function (username) { | |
$http.get("https://api.github.com/users/" + username) | |
.then(onUserComplete, onError) | |
} | |
$scope.username = "angular"; | |
$scope.message = "Angular! GitHub Viewer"; | |
$scope.repoSortOrder = "-stargazers_count"; | |
}; | |
app.controller("MainController", MainController); | |
} ()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment