File

src/dialog/overflow-menu/overflow-menu.directive.ts

Description

Directive for extending Dialog to create overflow menus.

class: OverflowMenuDirective (extends DialogDirective)

selector: ibmOverflowMenu

<div [ibmOverflowMenu]="templateRef"></div>
<ng-template #templateRef>
     <!-- overflow menu options here -->
</ng-template>

Metadata

providers DialogService
selector [ibmOverflowMenu]

Index

Methods
Inputs
HostListeners

Constructor

constructor(elementRef: ElementRef, viewContainerRef: ViewContainerRef, dialogService: DialogService)

Creates an instance of OverflowMenuDirective.

Parameters :
Name Type Optional Description
elementRef ElementRef
viewContainerRef ViewContainerRef
dialogService DialogService

Inputs

flip

Controls wether the overflow menu is flipped

Default value: false

ibmOverflowMenu

Takes a template ref of OverflowMenuOptionss

Type: TemplateRef<any>

HostListeners

keydown
Arguments : '$event'
keydown(event: KeyboardEvent)

Methods

onDialogInit
onDialogInit()
Returns : void
import {
	Directive,
	ElementRef,
	ViewContainerRef,
	Input,
	TemplateRef,
	HostListener
} from "@angular/core";
import { DialogDirective } from "./../dialog.directive";
import { DialogService } from "./../dialog.service";
import { OverflowMenuPane } from "./overflow-menu-pane.component";


/**
 * Directive for extending `Dialog` to create overflow menus.
 *
 * class: OverflowMenuDirective (extends DialogDirective)
 *
 *
 * selector: `ibmOverflowMenu`
 *
 *
 * ```html
 * <div [ibmOverflowMenu]="templateRef"></div>
 * <ng-template #templateRef>
 * 	<!-- overflow menu options here -->
 * </ng-template>
 * ```
 */
@Directive({
	selector: "[ibmOverflowMenu]",
	exportAs: "ibmOverflowMenu",
	providers: [
		DialogService
	]
})
export class OverflowMenuDirective extends DialogDirective {
	/**
	 * Takes a template ref of `OverflowMenuOptions`s
	 */
	@Input() ibmOverflowMenu: TemplateRef<any>;
	/**
	 * Controls wether the overflow menu is flipped
	 */
	@Input() flip = false;

	/**
	 * Creates an instance of `OverflowMenuDirective`.
	 */
	constructor(
		protected elementRef: ElementRef,
		protected viewContainerRef: ViewContainerRef,
		protected dialogService: DialogService
	) {
		super(elementRef, viewContainerRef, dialogService);
		dialogService.create(OverflowMenuPane);
	}

	onDialogInit() {
		this.dialogConfig.content = this.ibmOverflowMenu;
		this.dialogConfig.flip = this.flip;
	}

	@HostListener("keydown", ["$event"])
	hostkeys(event: KeyboardEvent) {
		switch (event.key) {
			case "Enter":
			case " ":
				this.toggle();
				break;
		}
	}
}

results matching ""

    No results matching ""