import { Component , EventEmitter , Input , Output } from '@angular/core' ; import { Sorter } from '@app/core/services/sort.service' ; import { FoodItem } from '@app/shared/models/foodItem.model' ; @ Component ( { selector : 'app-foodlist' , templateUrl : './food-list.component.html' , styleUrls : [ './food-list.component.css' ] } ) export class FoodListComponent { foodItem : FoodItem ; foodToDelete : FoodItem ; searchString : string ; @ Input ( ) foods : FoodItem [ ] ; @ Output ( ) foodSelected = new EventEmitter < FoodItem > ( ) ; @ Output ( ) foodDeleted = new EventEmitter < FoodItem > ( ) ; constructor ( private sorter ) { } setFoodToDelete ( foodItem ) { this . foodToDelete = foodItem ; } sortArray ( key , $event ) { if ( $event ) { $event . preventDefault ( ) ; } this . sorter . sort ( key , this . foods ) ; } }