diff options
Diffstat (limited to 'src/angular/tabs/tabs.component.ts')
-rw-r--r-- | src/angular/tabs/tabs.component.ts | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/angular/tabs/tabs.component.ts b/src/angular/tabs/tabs.component.ts index 595f304..c3b6507 100644 --- a/src/angular/tabs/tabs.component.ts +++ b/src/angular/tabs/tabs.component.ts @@ -1,8 +1,7 @@ -import { Component, Input, AfterContentInit, ContentChildren, QueryList, HostBinding } from '@angular/core'; +import { Component, Input, AfterContentInit, ContentChildren, QueryList, HostBinding, EventEmitter, Output } from '@angular/core'; import { TabComponent } from './children/tab.component'; -import { SvgIconComponent } from "./../../../src/angular/svg-icon/svg-icon.component"; -import { Mode, Placement, Size } from './../common/enums'; -import template from "./tabs.component.html"; +import { Mode, Size } from './../common/enums'; +import { template } from "./tabs.component.html"; @Component({ selector: 'sdc-tabs', @@ -12,20 +11,22 @@ import template from "./tabs.component.html"; export class TabsComponent implements AfterContentInit { @HostBinding('class') classes = 'sdc-tabs sdc-tabs-header'; - @ContentChildren(TabComponent) private tabs: QueryList<TabComponent>; + @ContentChildren(TabComponent) public tabs: QueryList<TabComponent>; + @Output() public selectedTab: EventEmitter<TabComponent> = new EventEmitter<TabComponent>(); public _size = Size.medium; public selectTab(tab: TabComponent) { - // deactivate all tabs - this.tabs.toArray().forEach((_tab: TabComponent) => { - _tab.active = false; - _tab.titleIconMode = Mode.secondary; - }); - - // activate the tab the user has clicked on. - tab.active = true; - tab.titleIconMode = Mode.primary; + this.selectedTab.emit(tab); + // deactivate all tabs + this.tabs.toArray().forEach((_tab: TabComponent) => { + _tab.active = false; + _tab.titleIconMode = Mode.secondary; + }); + + // activate the tab the user has clicked on. + tab.active = true; + tab.titleIconMode = Mode.primary; } public ngAfterContentInit() { @@ -38,4 +39,4 @@ export class TabsComponent implements AfterContentInit { } } - } +} |