import { Component , Input , Output , EventEmitter } from "@angular/core" ; import { Product } from "./product.service" ; @ Component ( { selector : "db-product-card" , template : require ( "./product-card.component.html" ) } ) export class ProductCardComponent { @ Input ( ) products : Product [ ] ; @ Output ( ) addToCart : EventEmitter < Product > = new EventEmitter < Product > ( ) ; setClasses ( product ) { return { "card-danger" : product . isSpecial , "card-inverse" : product . isSpecial } ; } buy ( product ) { this . addToCart . emit ( product ) ; } }