-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathapp.js
More file actions
42 lines (42 loc) · 855 Bytes
/
app.js
File metadata and controls
42 lines (42 loc) · 855 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
angular.module('app', [])
.component('todoList', {
controller: function() {
this.todos = [
"Wake up",
"play with my cat",
"hacking"
];
this.addTodo = () => {
this.todos.push(this.newTodo);
this.newTodo = "";
};
this.removeTodo = (index) => {
this.todos.splice(index, 1);
}
},
template: `
<h1>Todo List</h1>
<input ng-model="$ctrl.newTodo">
<button ng-click="$ctrl.addTodo()">add</button>
<ul>
<entry
todo="todo"
ng-repeat="todo in $ctrl.todos track by $index"
ng-click="$ctrl.removeTodo($index)"
/>
</ul>
<hr/>
<pre>{{$ctrl.todos}}<pre>
`
})
.component('entry', {
bindings: {
todo: '<'
},
template: `
<li
>
{{$ctrl.todo}}
</li>
`
})