File

src/tabs/tabs.component.ts

Description

Build out your application's tabs using this neutrino component. This is the parent of the Tab and TabHeader components.

Tabs expects a set of n-tab elements

<ibm-tabs>
     <ibm-tab heading='tab1'>
         tab 1 content
     </ibm-tab>
     <ibm-tab heading='tab1'>
         tab 2 content
     </ibm-tab>
     <!-- ... -->
     <ibm-tab heading='tab1'>
         tab n content
     </ibm-tab>
</ibm-tabs>

Implements

AfterContentInit

Example

Metadata

selector ibm-tabs

Index

Properties
Methods
Inputs

Inputs

cacheActive

Set to 'true' to have Tab items cached and not reloaded on tab switching.

Default value: false

position

Takes either the string value 'top' or 'bottom' to place TabHeader relative to the TabPanels.

Type: "top" | "bottom"

Default value: top

Methods

hasTabHeaders
hasTabHeaders()

true if the n-tab's are passed directly to the component as children

Returns : boolean
ngAfterContentInit
ngAfterContentInit()

After content is initialized update Tabs to cache (if turned on) and set the inital selected Tab item.

Returns : void

Properties

tabHeaders
tabHeaders:
Decorators : ContentChild

Content child of the projected header component

tabs
tabs: QueryList<Tab>
Type : QueryList<Tab>
Decorators : ContentChildren

Maintains a QueryList of the Tab elements and updates if Tabs are added or removed.

import {
	Component,
	Input,
	ContentChildren,
	QueryList,
	AfterContentInit,
	ContentChild,
	Query
} from "@angular/core";
import { Tab } from "./tab.component";
import { TabHeaders } from "./tab-headers.component";


/**
 * Build out your application's tabs using this neutrino component.
 * This is the parent of the `Tab` and `TabHeader` components.
 *
 * `Tabs` expects a set of `n-tab` elements
 *
 * ```html
 * <ibm-tabs>
 * 	<ibm-tab heading='tab1'>
 * 		tab 1 content
 * 	</ibm-tab>
 * 	<ibm-tab heading='tab1'>
 * 		tab 2 content
 * 	</ibm-tab>
 * 	<!-- ... -->
 * 	<ibm-tab heading='tab1'>
 * 		tab n content
 * 	</ibm-tab>
 * </ibm-tabs>
 * ```
 *
 * @export
 * @class Tabs
 * @implements {AfterContentInit}
 */
@Component({
	selector: "ibm-tabs",
	template: `
			<ibm-tab-headers
				*ngIf="hasTabHeaders() && position === 'top'"
				[tabs]="tabs"
				[cacheActive]="cacheActive">
			</ibm-tab-headers>
			<ng-content></ng-content>
			<ibm-tab-headers
				*ngIf="hasTabHeaders() && position === 'bottom'"
				[tabs]="tabs"
				[cacheActive]="cacheActive">
			</ibm-tab-headers>
	 `
})
export class Tabs implements AfterContentInit {
	/**
	 * Takes either the string value 'top' or 'bottom' to place TabHeader
	 * relative to the `TabPanel`s.
	 * @type string
	 * @memberof Tabs
	 */
	@Input() position: "top" | "bottom" = "top";
	/**
	 * Set to 'true' to have `Tab` items cached and not reloaded on tab switching.
	 * @memberof Tabs
	 */
	@Input() cacheActive = false;
	/**
	 * Maintains a `QueryList` of the `Tab` elements and updates if `Tab`s are added or removed.
	 * @type {QueryList<Tab>}
	 * @memberof Tabs
	 */
	@ContentChildren(Tab, { descendants: false }) tabs: QueryList<Tab>;
	/**
	 * Content child of the projected header component
	 */
	@ContentChild(TabHeaders) tabHeaders;

	/**
	 * After content is initialized update `Tab`s to cache (if turned on) and set the inital
	 * selected Tab item.
	 * @memberof Tabs
	 */
	ngAfterContentInit() {
		if (this.tabHeaders) {
			this.tabHeaders.cacheActive = this.cacheActive;
		}
	}

	/**
	 * true if the n-tab's are passed directly to the component as children
	 */
	hasTabHeaders() {
		return this.tabs.length > 0;
	}
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""