import { ChangeDetectionStrategy , Component , ContentChild , OnDestroy , TemplateRef } from '@angular/core' ; import { Observable } from 'rxjs' ; import { map } from 'rxjs/operators' ; import { CardTabsService } from '../card-tabs.service' ; import { CardTabContentDirective } from './card-tab-content.directive' ; @ Component ( { selector : 'ux-card-tab' , templateUrl : './card-tab.component.html' , changeDetection : ChangeDetectionStrategy . OnPush } ) export class CardTabComponent implements OnDestroy { active$ : Observable < boolean > = this . _tabService . tab$ . pipe ( map ( tab => tab === this ) ) ; @ ContentChild ( CardTabContentDirective , { read : TemplateRef , static : false } ) content : TemplateRef < any > ; constructor ( private _tabService ) { this . _tabService . addTab ( this ) ; } ngOnDestroy ( ) { this . _tabService . removeTab ( this ) ; } }