File

src/content-switcher/content-switcher.component.ts

Implements

AfterViewInit

Metadata

selector ibm-content-switcher

Index

Properties
Methods
Inputs
Outputs

Inputs

label

Default value: content switcher

Outputs

selected $event type: EventEmitter

Methods

ngAfterViewInit
ngAfterViewInit()
Returns : void

Properties

options
options: QueryList<ContentSwitcherOption>
Type : QueryList<ContentSwitcherOption>
Decorators : ContentChildren
import {
	Component,
	Input,
	ContentChildren,
	QueryList,
	Output,
	EventEmitter,
	AfterViewInit
} from "@angular/core";
import { ContentSwitcherOption } from "./content-switcher-option.directive";

/**
 *
 *
 */
@Component({
	selector: "ibm-content-switcher",
	template: `
		<div
			[attr.aria-label]="label"
			class="bx--content-switcher"
			role="tablist">
			<ng-content></ng-content>
		</div>
	`
})
export class ContentSwitcher implements AfterViewInit {
	@Input() label = "content switcher";

	@Output() selected = new EventEmitter();

	@ContentChildren(ContentSwitcherOption) options: QueryList<ContentSwitcherOption>;

	ngAfterViewInit() {
		this.options.forEach(option => {
			option.selected.subscribe(_ => {
				const active = option;
				this.options.forEach(option => {
					if (option !== active) {
						option.active = false;
					}
				});
				this.selected.emit(active);
			});
		});
	}
}
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""