Skip to content

Commit

Permalink
fix(tabs): removed onDestroy event
Browse files Browse the repository at this point in the history
fixes #696, fixes #610
  • Loading branch information
valorkin committed Dec 28, 2016
1 parent 92f82c0 commit 78f6e49
Showing 1 changed file with 19 additions and 26 deletions.
45 changes: 19 additions & 26 deletions src/tabs/tab.directive.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
import {
Directive, EventEmitter, HostBinding, Input, OnDestroy, Output, TemplateRef, OnInit
} from '@angular/core';

import { Directive, EventEmitter, HostBinding, Input, Output, TemplateRef, OnInit } from '@angular/core';
import { TabsetComponent } from './tabset.component';

@Directive({selector: 'tab, [tab]'})
export class TabDirective implements OnDestroy, OnInit {
export class TabDirective implements OnInit {
/** tab header text */
@Input() public heading:string;
@Input() public heading: string;
/** if true tab can not be activated */
@Input() public disabled:boolean;
@Input() public disabled: boolean;
/** if true tab can be removable, additional button will appear */
@Input() public removable:boolean;
@Input() public removable: boolean;
/** if set, will be added to the tab's class atribute */
@Input() public customClass:string;
@Input() public customClass: string;

/** tab active state toggle */
@HostBinding('class.active')
@Input()
public get active():boolean {
public get active(): boolean {
return this._active;
}

public set active(active:boolean) {
public set active(active: boolean) {
if (this.disabled && active || !active) {
if (!active) {
this._active = active;
Expand All @@ -34,36 +31,32 @@ export class TabDirective implements OnDestroy, OnInit {

this._active = active;
this.select.emit(this);
this.tabset.tabs.forEach((tab:TabDirective) => {
this.tabset.tabs.forEach((tab: TabDirective) => {
if (tab !== this) {
tab.active = false;
}
});
}

/** fired when tab became active, $event:Tab equals to selected instance of Tab component */
@Output() public select:EventEmitter<TabDirective> = new EventEmitter();
@Output() public select: EventEmitter<TabDirective> = new EventEmitter();
/** fired when tab became inactive, $event:Tab equals to deselected instance of Tab component */
@Output() public deselect:EventEmitter<TabDirective> = new EventEmitter();
@Output() public deselect: EventEmitter<TabDirective> = new EventEmitter();
/** fired before tab will be removed */
@Output() public removed:EventEmitter<TabDirective> = new EventEmitter();
@Output() public removed: EventEmitter<TabDirective> = new EventEmitter();

@HostBinding('class.tab-pane') public addClass:boolean = true;
@HostBinding('class.tab-pane') public addClass: boolean = true;

public headingRef:TemplateRef<any>;
public tabset:TabsetComponent;
protected _active:boolean;
public headingRef: TemplateRef<any>;
public tabset: TabsetComponent;
protected _active: boolean;

public constructor(tabset:TabsetComponent) {
public constructor(tabset: TabsetComponent) {
this.tabset = tabset;
this.tabset.addTab(this);
}

public ngOnInit():void {
this.removable = !!this.removable;
}

public ngOnDestroy():void {
this.tabset.removeTab(this);
public ngOnInit(): void {
this.removable = this.removable;
}
}

0 comments on commit 78f6e49

Please sign in to comment.