Attach the directive to the target for contextual actions. Give each item a stable key and handle the selected item in your application. Provide a visible action button so the same choices are available on touch.
Right-click the PDF card, focus it and press Shift+F10, or tap its options button. View details reveals the file metadata. Archive and Restore file update the cardโs local state; no file or server is changed. The item template receives each item through let-item.
The application owns the menu items, visible file details and archive state. openAt(x, y, origin) opens at viewport coordinates and restores focus to the supplied origin. The directive handles native contextmenu and ContextMenu/Shift+F10; the visible options button provides an explicit touch path.
Use a visible native button for the direct action path and a meaningful label for each item. Keep a custom item template presentational; the menu already provides the interactive element.
ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.
Name
Mechanism
Contract
NeuContextMenuItemDirective
Public template directive (entrypoint)
ng-template[neuContextMenuItem]
template.d.ts
import { NeuContextMenuItemDirective } from '@neural-ui/core/context-menu';
// Public declaration (reference only)
export declare class NeuContextMenuItemDirective {
}
context.d.ts
import type { NeuContextMenuItemContext } from '@neural-ui/core/context-menu';
import { NeuContextMenuItemDirective } from '@neural-ui/core/context-menu';
// Public declaration (reference only)
readonly templateRef: TemplateRef<NeuContextMenuItemContext>;
Usage example
Content between the button tags is projected content. You can supply text, an icon component or an SVG; the Icons section demonstrates these variants. For iconOnly, omit visible text and provide ariaLabel: projected content is not automatically removed.
Open a type to inspect its definition and interface fields.
NeuContextMenuItem.d.ts
import type { NeuContextMenuItem } from '@neural-ui/core/context-menu';
// Public declaration (reference only)
interface NeuContextMenuItem {
disabled?: boolean;
icon?: string;
key: string;
label: string;
separator?: boolean;
tone?: 'neutral' | 'danger';
}
NeuContextMenuItemContext.d.ts
import type { NeuContextMenuItem } from '@neural-ui/core/context-menu';
import type { NeuContextMenuItemContext } from '@neural-ui/core/context-menu';
// Public declaration (reference only)
interface NeuContextMenuItemContext {
$implicit: NeuContextMenuItem;
}