notifyCtrl.js
992 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
39
40
41
42
43
44
45
46
47
48
(function(angular) {
var itemMsg = 0;
/**
* notifyCtrl - controller
*/
function notifyCtrl($interval, notify,
commonResource) {
commonResource.notify(function(data) {
if (data.draw == 0) {
itemMsg = data.data.length;
$('.count-info').find("span").text(itemMsg);
}
});
var todo = function() {
commonResource.notify({}, function(data) {
if (data.draw != 0) {
/*swal({
title : "",
text : "提醒失败!",
timer : 1500,
type : "error",
showConfirmButton : false
});*/
} else {
notify.closeAll();
$('.count-info').find("span").text(data.data.length);
if (itemMsg < data.data.length) {
notify({
message : 'Hi, 你有新信息!',
classes : 'alert-info',
duration: 1500
});
}
itemMsg = data.data.length;
}
});
};
$interval(todo, 1000 * 15);
}
angular.module('inspinia').controller('notifyCtrl', notifyCtrl);
})(angular);