Skip to content

Instantly share code, notes, and snippets.

@bolenton
Created July 17, 2016 23:08
Show Gist options
  • Save bolenton/1d6925c54b58d2d548ebae8ccfb41e4f to your computer and use it in GitHub Desktop.
Save bolenton/1d6925c54b58d2d548ebae8ccfb41e4f to your computer and use it in GitHub Desktop.
(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