File

packages/ui/src/lib/utility/tab/tab.component.ts

Description

A Tab is meant to be placed inside TabsComponent

Metadata

selector ec-tab
templateUrl ./tab.component.html

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(el: ElementRef)

The constructor adds the tab itself to its TabsComponent parent.

Parameters :
Name Type Optional
el ElementRef No

Inputs

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.

Outputs

activated
Type : EventEmitter<any>

Output that emits when the tab is activated

deactivated
Type : EventEmitter<any>

Output that emits when the tab is deactivated

Methods

activate
activate()

Selects the tab and nexts activated

Returns : void
deactivate
deactivate()

Deselects the tab and nexts activated

Returns : void

Properties

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>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""