File size: 1,060 Bytes
b3787d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
var Todo = ng
    .core
	.Component({
		selector: 'todo',
		templateUrl: 'partials/todo2.html' ,
        directives: [ng.common.CORE_DIRECTIVES, ng.common.FORM_DIRECTIVES],
	})
	.Class({
		constructor: function() {
			this.label = '';
			this.todos = [{
					label: 'Learn Angular',
					complete: false	
				},{
					label: 'Learn Angular2',
					complete: false
				},{
					label: 'Learn React',
					complete: false	
				},{
					label: 'Learn Redux',
					complete: false
				},{
					label: 'Learn Alt',
					complete: false
				}];			
		},
		
		updateIncomplete: function() {
			return this.todos.filter(function(item) {
				return !item.complete;
			}).length;
		},
				
		deleteItem: function(index) {
			this.todos.splice(index, 1);
		},				
				
		onSubmit: function(event) {
			event.preventDefault();	
			if (this.label.length) {
				this.todos.unshift({
					label: this.label,
					complete: false
				});
				this.label = '';
			}
		}	
	});
		
document.addEventListener('DOMContentLoaded', function() {
	ng.platform.browser.bootstrap(Todo);
});