New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

context-menu-angular6

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

context-menu-angular6

Right click context menu for Angular 6 based on ng2-right-click-menu from https://github.com/msarsha/ng2-right-click-menu

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

context-menu-angular6

Right click context menu for Angular 6 based on ng2-right-click-menu from https://github.com/msarsha/ng2-right-click-menu just added some updates for angular 6

DEMO https://msarsha.github.io/ng2-right-click-menu/

Dependencies

@angular/cdk

@angular/cdk/overlay-prebuilt.css

Setup

npm install --save context-menu-angular6 @angular/cdk

import ShContextMenuModule

import {ShContextMenuModule} from 'context-menu-angular6'

@NgModule({
  //...
  imports: [ShContextMenuModule]
  //...
})

import css file in your styles.css:

  @import "~@angular/cdk/overlay-prebuilt.css";

Usage

Defining a Basic Menu Template

The menu template is built using the sh-context-menu component as the menu wrapper, and nested ng-template with the shContextMenuItem directive for every menu item:

The shContextMenuItem directive provide a template variable (let-data) that gives you access to the data object attached to the menu.

<sh-context-menu #menu>
  <ng-template shContextMenuItem let-data (click)="onClick($event)">
    <div>
      Menu Item - {{data.label}}
    </div>
  </ng-template>
</sh-context-menu>

Attaching Menu To An Element

Attaching works by using the shAttachMenu directive and providing the #menu (from the above example) template variable:

The object provided to the [shMenuData] input will be available as a template variable inside ng-templates with shContextMenuItem

<div [shAttachMenu]="menu" [shMenuData]="data">Right Click Me</div>

Sub Menus

Sub menu is attached to the shContextMenuItem directive using the [subMenu] input.

The [subMenu] input is provided with a sh-context-menu's template variable (just like attaching a menu to an element).

<sh-context-menu #menu>
  <ng-template shContextMenuItem let-data [subMenu]="#nestedMenu">
    <div>
      Menu Item - {{data.label}}
    </div>
  </ng-template>
  <sh-context-menu #nestedMenu>
    <ng-template shContextMenuItem let-data>
      <div>
        Menu Item - {{data.label}}
      </div>
    </ng-template>
  </sh-context-menu>
</sh-context-menu>

API

sh-context-menu (component)

NameTypeDefaultDescription
[this]anynullthe this context for input callbacks (visible) - typically the menu's host component

shContextMenuItem (directive)

NameTypeDefaultDescription
[subMenu]ShContextMenuComponentnullsub menu
[divider]booleanfalserender a divider
[closeOnClick]booleantrueshould the menu close on click
[visible](event: ShContextMenuClickEvent) => booleannullfunction to determine if a item is visible
(click)(event: ShContextMenuClickEvent) => voidnullclick handler

shAttachMenu (directive)

NameTypeDefaultDescription
[shAttachMenu]ShContextMenuComponentnullthe menu that will be attached to the element
[shMenuTriggers]string[]nulllist of event names that will trigger the menu
[shMenuData]anynullthe data object that will be injected to the menu item's template

Setting up development env

npm start to run the demo application

develop the library under /lib

context-menu-angular6

Keywords

angular6

FAQs

Package last updated on 20 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts