-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.service.js
63 lines (54 loc) · 1.55 KB
/
common.service.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* Common Service
* @namespace Services
*/
(function () {
'use strict';
angular
.module('app')
.factory('common', common);
/**
* @namespace common
* @desc Includes common services used across applications
* @requires RestService
* @memberOf Services
*/
function common($q, $timeout, $rootScope, $interval,
$location, lodash) {
"ngInject";
var service = {
$broadcast: $rootScope.$broadcast,
$interval: $interval,
$location: $location,
$timeout: $timeout,
$rootScope: $rootScope,
$q: $q,
lodash: lodash,
};
return service;
/**
* @namespace getMoreItems
* @desc Facilitates the getting of more data for a paginated list
* @requires LoaderService, ScrollLoader Directive
* @memberOf Services
*/
function getMoreItems(listVar, next, loader) {
if (!loader) {
loader = {
spin: LoaderService.spin,
start: LoaderService.scrollStart,
stop: LoaderService.scrollStop
};
}
if (next && loader.spin === false) {
var currentPage = listVar.$metadata.page;
loader.start();
listVar
.$fetch({ page: currentPage + 1 })
.$then(function(){
loader.stop();
});
}
}
}
}());