import { ChangeDetectionStrategy , Component , Input , OnDestroy , OnInit } from '@angular/core' ; import { ActivatedRoute , ParamMap } from '@angular/router' ; import { Subscription } from 'rxjs' ; import { ContributorService } from '@core/contributor.service' ; import { EventService } from '@core/event.service' ; param productType { string } @ Component ( { changeDetection : ChangeDetectionStrategy . OnPush , selector : 'product-page' , styleUrls : [ './product-page.component.scss' ] , templateUrl : './product-page.component.html' } ) export class ProductPageComponent implements OnInit , OnDestroy { @ Input ( ) productType : string ; queryParamMapSubscription : Subscription ; @ Input ( ) showAllProducts = true ; @ Input ( ) showVersion = false ; constructor ( public contributorService , public eventService , public route ) { } ngOnDestroy ( ) { this . queryParamMapSubscription . unsubscribe ( ) ; } ngOnInit ( ) { this . queryParamMapSubscription = this . route . queryParamMap . subscribe ( ( paramMap ) => { this . onQueryParamMapChange ( paramMap ) ; } ) ; } param paramMap { ParamMap } onQueryParamMapChange ( paramMap ) { const source = paramMap . get ( 'source' ) ; const code = paramMap . get ( 'code' ) ; this . eventService . getProduct ( this . productType , source , code ) ; } }