Angular right click and context menu library. No dependencies.
-
Copy/move
ng-right-click.jsfromsrcdir in the package to your project dir -
In your Angular app, add a dependency to your module as below:
angular.module('yourApp',['ngRightClick',...]');
In your project dir, type the following command:
$ bower install angular-right-clickThen add a <script> in your project html:
<script src='/bower_components/angular-right-click/src/ng-right-click.js'></script>And finally in your Angular app, add the dependency as:
angular.module('yourApp',['ngRightClick',...]');
In your project dir, run the following command:
$ npm install angular-right-clickThen require() in your project source as:
require('angular-right-click')Import default css file in your project index file as:
<link rel="stylesheet" href="[node_modules | bower_components]/angular-right-click/src/css/ng-right-click.css"><div ng-right-click="someFunction()"></div>In your html file, use the component like this:
<div ng-right-click menu-items="menuItems"></div><div ng-right-click="someFunction()" menu-items="menuItems"></div>where the data format is (in your controller):
$scope.sayHello = function(){
//say hello!
};
$scope.menuItems = [
{ text: "Menu Item 1", //menu option text
disabled: true //No click event. Grayed out option.
},
{
text:"Menu Item 2",
callback: sayHello, //function to be called on click
disabled: false
}
];I have included a default css file for default styling. Include it in your file. You can easily override it with your custom css class lie that:
<div ng-right-click menu-items="menuItems" menu-class="custom-css-class"></div>Please check the examples directory to get the gist!
Check code example here.