Skip to content

Instantly share code, notes, and snippets.

@nitayneeman
Last active September 11, 2017 16:02
Show Gist options
  • Save nitayneeman/3f9e6559b2cb0006a45da5d310ec1bf4 to your computer and use it in GitHub Desktop.
Save nitayneeman/3f9e6559b2cb0006a45da5d310ec1bf4 to your computer and use it in GitHub Desktop.
@Component({
selector: 'my-app',
templateUrl: './app.component.html'
})
export class AppComponent {
public todos: string[];
constructor(private appService: AppService) {
this.todos = ['Todo', 'Todo', 'Todo'];
}
addTodo(): void {
this.appService
.fetchData()
.subscribe((todo: string) => this.todos.push(todo));
}
removeTodo(index: number): void {
this.todos.splice(index, 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment