-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
48 lines (41 loc) · 1.06 KB
/
example.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
// Code goes here
var todosControl = function ($scope) {
$scope.todos = [{
text: 'Integrate magnum',
done: true
}, {
text: 'Leverage magnum into my app',
done: false
}];
$scope.remaining = function () {
var count = 0;
$.each($scope.todos, function (k, todo) {
count += todo.done ? 0 : 1;
});
return count;
};
$scope.size = function () {
return $scope.todos.length;
};
}
mag.observe().on('tmpl-begin', function (name) {
$('#' + name).hide();
});
mag.observe().on('tmpl-end', function (name) {
if (name == 'todosControl') {
$('#' + name).show();
var ctrl = new mag.watch();
ctrl.secret = 'null';
ctrl._bind($('#todoText'), 'secret');
ctrl._watch($('.output'), 'secret');
}
});
mag.control('todosControl', ['test', todosControl]);
$('.todos').addClass('more');
setTimeout(function () {
mag.control('todosControl', ['',
function ($scope) {
$scope.todos[0].done = false;
}
]);
}, 1000);