import { AfterViewInit , Component , OnDestroy } from '@angular/core' ; import { Subscription } from 'rxjs' ; import { EventService } from '@core/event.service' ; import { OafService } from '../oaf.service' ; /**
 * Display OAF product page with tabs
 */ @ Component ( { selector : 'oaf' , styleUrls : [ './oaf.component.scss' ] , templateUrl : './oaf.component.html' } ) export class OafComponent implements AfterViewInit , OnDestroy { subscription : Subscription = new Subscription ( ) ; constructor ( public eventService , public oafService ) { } ngAfterViewInit ( ) { this . subscription . add ( this . eventService . product$ . subscribe ( product => { return this . onProduct ( product ) ; } ) ) ; } ngOnDestroy ( ) { this . subscription . unsubscribe ( ) ; } param product onProduct ( product ) { if ( product && product . type === 'oaf' ) { this . oafService . getOaf ( product ) ; } } }