import { Component , OnInit } from '@angular/core' ; import { ProductService } from "../shared/product.service" ; @ Component ( { selector : 'app-product' , templateUrl : './product.component.html' , styleUrls : [ './product.component.css' ] } ) export class ProductComponent implements OnInit { private products : Array < Product > ; private imgUrl = 'http://placehold.it/320x150' ; constructor ( private productService ) { } ngOnInit ( ) { this . products = this . productService . getProducts ( ) ; } } export class Product { constructor ( public id , public title , public price , public rating , public desc , public categories ) { } }