/** * The main component that renders single TabComponent * instances. */ import { Component, ContentChildren, QueryList, AfterContentInit, Output, EventEmitter, ViewChild, ElementRef, } from '@angular/core'; import { TabComponent } from './tab.component'; declare var UIkit: any; @Component({ selector: 'my-small-tabs', template: `
` }) export class SmallTabsComponent implements AfterContentInit { @ViewChild('drop_element') dropElement: ElementRef; @ContentChildren(TabComponent) tabs: QueryList; @Output() public selectedActiveTab: EventEmitter = new EventEmitter(); public activeTab: TabComponent = null; // contentChildren are set ngAfterContentInit() { // if there is no active tab set, activate the first if(this.tabs && this.tabs.length > 0) { this.selectTab(this.tabs.first); } } selectTab(tab: TabComponent){ this.activeTab = tab; // activate the tab the user has clicked on. this.selectedActiveTab.emit(tab.tabId); if(typeof document !== 'undefined' && this.dropElement) { UIkit.drop(this.dropElement.nativeElement).hide(false); } } }