forked from almuhder/AngularJS-ToDo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (36 loc) · 1.01 KB
/
app.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
// app.js
angular.module('app', []).component('todoList', {
// TODO
controller: function () {
this.todos = [
'Update the front end',
'Fix the login problem',
'Get the last batch',
];
this.addToDo = () => {
this.todos.push(this.newToDo);
console.log(this.newToDo);
this.newToDo = '';
};
this.removeToDo = (index) => {
console.log(index);
this.todos.splice(index, 1);
// this.todos.pop();
};
this.editToDo = ($index) => {
console.log(index);
};
},
template: `
<h1> To Do List</h1>
<div class="form-group row">
<input class="form-control" ng-model="$ctrl.newToDo">
<button class="btn btn-primary" ng-click="$ctrl.addToDo()"> Add </button>
</div>
<ul>
<li ng-repeat="todo in $ctrl.todos" ng-click="$ctrl.removeToDo($index)"> {{todo}}</li>
</ul>
<hr />
<pre>{{$ctrl.todos | json}} </pre>
`,
});