File

src/content-switcher/content-switcher-option.directive.ts

Metadata

Selector [ibmContentOption]

Index

Properties
Inputs
Outputs
HostBindings
HostListeners
Accessors

Inputs

active

Used to activate the option. Only one option may be active at a time

Type : boolean

name

Internal name for the option. Should be something that identifies the option to the application. Accessible from the ContentSwitcher selected emitter

Default value : "option"

Outputs

selected

Emits when the option is selected.

$event Type: EventEmitter

HostBindings

attr.aria-selected
attr.aria-selected:
Default value : false
attr.role
attr.role:
Default value : "tab"
attr.tabIndex
attr.tabIndex:
Default value : "-1"
class
class:
Default value : "bx--content-switcher-btn"
class.bx--content-switcher--selected
class.bx--content-switcher--selected:
Default value : false

HostListeners

click
click()
focus
focus()

Properties

Protected _active
_active:
Default value : false

Accessors

active
getactive()
setactive(value: boolean)

Used to activate the option. Only one option may be active at a time

Parameters :
Name Type Optional
value boolean No
Returns : void
import {
	Directive,
	HostBinding,
	Input,
	HostListener,
	Output,
	EventEmitter
} from "@angular/core";

@Directive({
	selector: "[ibmContentOption]"
})
export class ContentSwitcherOption {
	/**
	 * Used to activate the option. Only one option may be `active` at a time
	 */
	@Input() set active (value: boolean) {
		this._active = value;
		this.selectedClass = value;
		this.ariaSelected = value;
		this.tabindex = value ? "0" : "-1";
	}

	get active() {
		return this._active;
	}

	/**
	 * Internal name for the option.
	 * Should be something that identifies the option to the application.
	 * Accessible from the `ContentSwitcher` `selected` emitter
	 */
	@Input() name = "option";

	/**
	 * Emits when the option is selected.
	 */
	@Output() selected = new EventEmitter();

	@HostBinding("class") switcherClass = "bx--content-switcher-btn";
	@HostBinding("class.bx--content-switcher--selected") selectedClass = false;
	@HostBinding("attr.role") role = "tab";
	@HostBinding("attr.aria-selected") ariaSelected = false;
	@HostBinding("attr.tabIndex") tabindex = "-1";

	protected _active = false;

	@HostListener("click")
	hostClick() {
		this.active = true;
		this.selected.emit(true);
	}

	@HostListener("focus")
	onFocus() {
		this.active = true;
		this.selected.emit(true);
	}
}

result-matching ""

    No results matching ""