-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
37 lines (31 loc) · 846 Bytes
/
app.ts
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
/// <reference path="typings/angular2/angular2.d.ts" />
import {bind, Inject, Component, View, bootstrap, CORE_DIRECTIVES} from 'angular2/angular2';
import {TodoService} from 'todoService';
@Component({
selector: 'todo-app',
services: [TodoService]
})
@View({
templateUrl: 'todo.html',
directives: [CORE_DIRECTIVES]
})
export class TodoApp {
title: string;
todoService: TodoService;
constructor(@Inject('TodoService') todoService: TodoService) {
this.todoService = todoService;
this.title = 'My TODO app';
}
keyup(newTodo, $event) {
if ($event.which === 13) {
this.addTodo(newTodo);
}
}
addTodo(newTodo):void {
this.todoService.addTodo(newTodo.value);
newTodo.value = '';
newTodo.focus();
}
}
}
bootstrap(TodoApp, [TodoService, bind('TodoService').toClass(TodoService)]);