-
Notifications
You must be signed in to change notification settings - Fork 0
/
monitor.js
62 lines (54 loc) · 1.69 KB
/
monitor.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
"use strict";
function createMonitor(tag) {
var Great = ng.core.Pipe({
name: 'great'
}).Class({
constructor: function () {
},
transform: function (value) {
return value.toUpperCase();
}
});
var MonitorComponent = ng.core.Component({
selector: tag,
templateUrl: 'monitor.html',
pipes: [Great]
}).Class({
constructor: [MyService, function (myService) {
this.myName = "Alice";
this.persons = [];
this.done = false;
var that = this;
myService.getPersons(function(value) {
that.persons = value;
});
this.count = 0;
var interval1 = setInterval(function () {
that.persons.push({
name: 'Seppi',
age: 56
});
that.count++;
if (that.count >= 10) {
clearInterval(interval1);
that.done = true;
}
}, 1000);
var interval2 = setInterval(function () {
var idx = parseInt(Math.random() * that.persons.length);
that.persons[idx].age = that.persons[idx].age * 2;
that.count++;
if (that.count >= 10) {
clearInterval(interval2);
that.done = true;
}
}, 1500);
}],
getPersonCount: function () {
return this.persons.length;
}
});
document.addEventListener('DOMContentLoaded', function () {
ng.platform.browser.bootstrap(MonitorComponent, [MyService, Great]);
});
}