src/dialog/overflow-menu/overflow-menu.directive.ts
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>
| providers |
DialogService
|
| selector | [ibmOverflowMenu] |
Methods |
Inputs |
HostListeners |
constructor(elementRef: ElementRef, viewContainerRef: ViewContainerRef, dialogService: DialogService)
|
||||||||||||||||
|
Creates an instance of
Parameters :
|
flip
|
Controls wether the overflow menu is flipped
Default value: |
ibmOverflowMenu
|
Takes a template ref of
Type: |
| keydown |
Arguments : '$event'
|
keydown(event: KeyboardEvent)
|
| 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;
}
}
}