Last active
August 29, 2015 14:05
-
-
Save junwatu/ba55d178b42c0324506b to your computer and use it in GitHub Desktop.
A Pen by Equan Pr..
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
<div ng-app="App" ng-controller="AppController"> | |
<h1>My Repository List</h1> | |
<p ng-repeat="repo in repos | orderBy:predicate:false">☠ {{repo.name}}</p> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script> |
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
var App = angular.module('App', []); | |
App.service('GithubService', function($http, $q){ | |
var deferred = $q.defer(); | |
this.getRepo = function(){ | |
$http.get('https://api.github.com/users/junwatu/repos') | |
.success(function(repos){ | |
deferred.resolve(repos); | |
}) | |
.error(function(){ | |
deferred.reject('Error!'); | |
}) | |
return deferred.promise; | |
} | |
}); | |
App.controller('AppController', function($scope, GithubService){ | |
GithubService.getRepo() | |
.then(function(data){ | |
console.log(data); | |
$scope.repos = data; | |
}) | |
.catch(function(err){ | |
alert(err); | |
}); | |
$scope.predicate='-name'; | |
}) |
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
body { | |
background-color: #1d1f20; | |
color: white; | |
padding: 10px 0px 0px 20px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment