packages/ui/src/lib/utility/tab/tab.component.ts
A Tab is meant to be placed inside TabsComponent
selector | ec-tab |
templateUrl | ./tab.component.html |
Properties |
Methods |
Inputs |
Outputs |
constructor(el: ElementRef)
|
||||||
The constructor adds the tab itself to its TabsComponent parent.
Parameters :
|
label | |
Type : string
|
|
The tab's label |
route | |
Type : string
|
|
If set, the tab will be selected when the given (relative) route is active. |
selected | |
Type : boolean
|
|
If set to true, the tab will be selected at start. |
activated | |
Type : EventEmitter<any>
|
|
Output that emits when the tab is activated |
deactivated | |
Type : EventEmitter<any>
|
|
Output that emits when the tab is deactivated |
activate |
activate()
|
Selects the tab and nexts activated
Returns :
void
|
deactivate |
deactivate()
|
Deselects the tab and nexts activated
Returns :
void
|
Public el |
Type : ElementRef
|
parent |
Type : TabsComponent
|
The parent TabsComponent |
import { Component, ElementRef, EventEmitter, Input, Output } from '@angular/core';
import { TabsComponent } from '../tabs/tabs.component';
/** A Tab is meant to be placed inside TabsComponent */
@Component({
selector: 'ec-tab',
templateUrl: './tab.component.html',
})
export class TabComponent {
/** The tab's label */
@Input() label: string;
/** If set to true, the tab will be selected at start. */
@Input() selected: boolean;
/** If set, the tab will be selected when the given (relative) route is active. */
@Input() route: string;
/** Output that emits when the tab is activated */
@Output() activated: EventEmitter<any> = new EventEmitter();
/** Output that emits when the tab is deactivated */
@Output() deactivated: EventEmitter<any> = new EventEmitter();
/** The parent TabsComponent */
parent: TabsComponent;
/** The constructor adds the tab itself to its TabsComponent parent. */
constructor(public el: ElementRef) {}
/** Selects the tab and nexts activated */
activate() {
this.selected = true;
this.activated.next();
}
/** Deselects the tab and nexts activated */
deactivate() {
this.selected = false;
this.deactivated.next();
}
}
<div class="ec-tab" *ngIf="selected">
<ng-content></ng-content>
</div>