|
1 | 1 | var Poly = angular.module('poly', []); |
2 | 2 |
|
3 | | -Poly.controller('UserListController', function($scope, $http, $q) { |
| 3 | +Poly.factory('users', function () { |
| 4 | + return [ |
| 5 | + { "github" : "markmandel", "nick" : "[Neurotic]", "lang" : "Go, Clojure, J/Ruby" }, |
| 6 | + { "github" : "andrebuchanan", "nick" : "andrebuchanan", "lang" : "Node.js" }, |
| 7 | + { "github" : "aussiegeek", "nick" : "aussiegeek", "lang" : "Ruby, Go" }, |
| 8 | + { "github" : "mwotton", "nick" : "blackdog", "lang" : "Haskell, Ansible, not-Javascript, not-Go." }, |
| 9 | + { "github" : "bulkan", "nick" : "bulkan", "lang" : "Node.js" }, |
| 10 | + { "github" : "cgiffard", "nick" : "cgiffard", "lang" : "Node.js, Erlang" }, |
| 11 | + { "github" : "deoxxa", "nick" : "deoxxa", "lang" : "Node.js, C" }, |
| 12 | + { "github" : "eugeneware", "nick" : "eugeneware", "lang" : "Node.js" }, |
| 13 | + { "github" : "joshwnj", "nick" : "joshwnj", "lang" : "Node.js, PHP" }, |
| 14 | + { "github" : "michaelneale", "nick" : "michaelneale", "lang" : "Erlang, Clojure, Scala, Bash, Haskell, Go, Javascript." }, |
| 15 | + { "github" : "nicholasf", "nick" : "nicholasf", "lang" : "Elixir, Javascript, post Ruby, post Java." }, |
| 16 | + { "github" : "ocke", "nick" : "ocke", "lang" : "Javascript, PHP" }, |
| 17 | + { "github" : "pomke", "nick" : "pomke", "lang" : "Javascript, Python" }, |
| 18 | + { "github" : "rkstedman", "nick" : "rkstedman", "lang" : "Node.js" }, |
| 19 | + { "github" : "robzolkos", "nick" : "robzolkos", "lang" : "Ruby, Node.js, Javascript, Go" }, |
| 20 | + { "github" : "rvagg", "nick" : "rvagg", "lang" : "Node.js" }, |
| 21 | + { "github" : "SomeoneWeird", "nick" : "SomeoneWeird", "lang" : "Javascript, Go" }, |
| 22 | + { "github" : "sporto", "nick" : "sporto", "lang" : "Javascript, Ruby, Go" }, |
| 23 | + { "github" : "timoxley", "nick" : "timoxley", "lang" : "Node.js" }, |
| 24 | + { "github" : "yangwao", "nick" : "wao-ender", "lang" : "Node.js" } |
| 25 | + ]; |
| 26 | +}); |
4 | 27 |
|
5 | | - $http.get('./js/users.json').then(function(res) { |
6 | | - $scope.details = {}; |
7 | | - $scope.users = res.data; |
8 | | - var git = []; |
9 | | - angular.forEach($scope.users, function(u) { |
10 | | - git.push($http.get('https://api.github.com/users/'+u.github)); |
11 | | - }); |
12 | | - $q.all(git).then(function(res) { |
13 | | - angular.forEach(res, function(item) { |
14 | | - $scope.details[item.data.login] = item.data; |
15 | | - }); |
| 28 | +Poly.controller('UserListController', function($scope, $http, $q, users) { |
| 29 | + $scope.details = {}; |
| 30 | + $scope.users = users; |
| 31 | + var git = []; |
| 32 | + angular.forEach($scope.users, function(u) { |
| 33 | + git.push($http.get('https://api.github.com/users/'+u.github)); |
| 34 | + }); |
| 35 | + $q.all(git).then(function(res) { |
| 36 | + angular.forEach(res, function(item) { |
| 37 | + $scope.details[item.data.login] = item.data; |
16 | 38 | }); |
17 | 39 | }); |
18 | 40 | }); |
0 commit comments