Created
September 10, 2017 13:04
-
-
Save karthikchintala1/136fe161e3f09f3d9e082530e6d383b1 to your computer and use it in GitHub Desktop.
the todo component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, ViewChild } from '@angular/core'; | |
import { TodoListComponent } from './todolist.component'; | |
@Component({ | |
selector: 'app-todo', | |
template: ` | |
<div> | |
<input type="text" placeholder="add a todo item here" [(ngModel)]="todotext"/> | |
<input type="submit" (click)="addItem()" value="Add Todo" /> | |
</div> | |
` | |
}) | |
export class TodoComponent { | |
@ViewChild(TodoListComponent) listComp: TodoListComponent; | |
todotext = ''; | |
addItem(): void { | |
this.listComp.addTodo(this.todotext); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment