Skip to content

Instantly share code, notes, and snippets.

@karthikchintala1
Created September 10, 2017 13:04
Show Gist options
  • Save karthikchintala1/136fe161e3f09f3d9e082530e6d383b1 to your computer and use it in GitHub Desktop.
Save karthikchintala1/136fe161e3f09f3d9e082530e6d383b1 to your computer and use it in GitHub Desktop.
the todo component
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