# @df-legacy/ng-context-menu

> An AngularJS directive to display a context menu when a right-click event is triggered

Latest version **1.0.2** (published 2021-10-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @df-legacy/ng-context-menu
pnpm add @df-legacy/ng-context-menu
yarn add @df-legacy/ng-context-menu
bun add @df-legacy/ng-context-menu
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-10-04 |
| First published | 2021-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | di9 |
| Keywords | ng-context-menu, context menu, right click, angularjs, angular |

## Links

- npm: https://www.npmjs.com/package/@df-legacy/ng-context-menu
- Repository: https://stash.sigma.sbrf.ru:7999/device_farm/ng-context-menu
- Homepage: http://ianwalter.github.io/ng-context-menu/
- npm.io page: https://npm.io/package/@df-legacy/ng-context-menu

## Recent versions

- 1.0.2 (latest) — 2021-10-04

## README

Originally ianwalter/ng-context-menu

This project is not maintained any longer. Please feel free to fork it if you need to make changes to the library.

# [ng-context-menu](http://ianwalter.github.io/ng-context-menu/)
*An AngularJS directive to display a context menu when a right-click event is triggered*

#### Step 1: Install ng-context-menu

Install using Bower:

```
bower install ng-context-menu --save
```

Include ng-context-menu.min.js in your app.

#### Step 2: Load the ng-context-menu module

```javascript
var app = angular.module('menu-demo', ['ngRoute', 'ng-context-menu'])
```

#### Step 3: Add the context-menu directive to a DOM element

```html
<div context-menu class="panel panel-default position-fixed"
     data-target="menu-{{ $index }}"
     ng-class="{ 'highlight': highlight, 'expanded' : expanded }">
  ...
</div>
```
#### Step 4: Add the markup of the menu you want to be displayed

Customize the menu to your needs. It may look something like:

```html
<div class="dropdown position-fixed" id="menu-{{ $index }}">
  <ul class="dropdown-menu" role="menu">
    <li>
      <a class="pointer" role="menuitem" tabindex="1"
         ng-click="panel.highlight = true">
         Select Panel {{ $index + 1 }}
      </a>
    </li>
    <li>
      <a class="pointer" role="menuitem" tabindex="2"
         ng-click="panel.highlight = false">
         Deselect Panel  {{ $index + 1 }}
      </a>
    </li>
    <li>
      <a class="pointer" role="menuitem" tabindex="3"
         ng-click="panel.expanded = true">
         Expand Panel {{ $index + 1 }}
      </a>
    </li>
    <li>
      <a class="pointer" role="menuitem" tabindex="4"
         ng-click="panel.expanded = false">
         Contract Panel {{ $index + 1 }}
      </a>
    </li>
    <li>
      <a class="pointer" role="menuitem" tabindex="5"
         ng-click="addPanel()">
         Add a panel
      </a>
    </li>
    <li>
      <a href="https://github.com/ianwalter/ng-context-menu"
         role="menuitem"
         tabindex="-1">
         ng-context-menu on GitHub
      </a>
    </li>
  </ul>
</div>
```

#### Step 5: Make sure your menu is has the ```position: fixed``` CSS property

As you can see in the demo, I just created a class called position-fixed and added the property:

```css
.position-fixed {
  position: fixed;
}
```

#### Disabling the contextmenu

If you need to disable the contextmenu in certain circumstances, you can add an expression to the
 ```context-menu-disabled``` attribute. If the expression evaluates to true, the contextmenu will be
 disabled, for example, ```context-menu-disabled="1 === 1"```

That's it, I hope you find this useful!

#### `close` Callback

Add the following attribute to the `context-menu` element: `context-menu-close` which should be a function
that will be called whenever the context menu is closed.

```html
<div context-menu="onShow()" context-menu-close="onClose()"></div>
```

«–– [Ian](http://ianvonwalter.com)

---
_Source: https://npm.io/package/@df-legacy/ng-context-menu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
