PuppetsController.js
996 Bytes
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
angular.module('footyroom')
.controller('PuppetsController', ['$http', function ($http) {
const ctrl = this;
var offset = 0;
ctrl.loadMore = loadMore;
ctrl.searchAccounts = searchAccounts;
ctrl.getAccounts = getAccounts;
getAccounts();
function getAccounts() {
$http.get('/puppets.json', {
params: {
offset: offset,
username: ctrl.username,
},
})
.success(function (response) {
if (offset > 0) {
ctrl.accounts = ctrl.accounts.concat(response);
} else {
ctrl.accounts = response;
}
});
}
function loadMore() {
offset += 20;
getAccounts();
}
function searchAccounts() {
offset = 0;
getAccounts();
}
}]);