import { Component , OnInit } from '@angular/core' ; import { DataService } from './../../Services/data.service' ; @ Component ( { selector : 'todo-list' , templateUrl : './todo-list.component.html' , styleUrls : [ './todo-list.component.css' ] } ) export class TodoListComponent implements OnInit { todos : Array < Object > = [ ] ; private todo : Object = { } ; constructor ( private _dataService ) { this . _dataService . getTodos ( ) . subscribe ( res => this . todos = res ) ; } ngOnInit ( ) { } onTodoDelete ( todoId ) { this . _dataService . deleteTodo ( todoId ) . subscribe ( res => { this . todos = this . todos . filter ( ( todo ) => { return todo . _id != todoId ; } ) ; console . log ( res ) ; } ) ; } }