Skip to content

Commit ee5d3e1

Browse files
committed
Update readme
1 parent 9159d00 commit ee5d3e1

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.check.workspaceVersion": false
3+
}

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class MyContextMenuClass {
4040
public items = [
4141
{ name: 'John', otherProperty: 'Foo' },
4242
{ name: 'Joe', otherProperty: 'Bar' }
43-
};
43+
];
4444
@ViewChild(ContextMenuComponent) public basicMenu: ContextMenuComponent;
4545
}
4646
```
@@ -73,6 +73,21 @@ public isMenuItemType1(item: any): boolean {
7373
}
7474
```
7575

76+
## Binding `this` for `visible` and `enabled` functions
77+
78+
If you need access to properties in your component from within the `enabled` or `visible` functions, you'll need to pass in a version of the function with `this` bound to your component.
79+
80+
```html
81+
<template ... [visible]="isMenuItemOutsideValueBound">
82+
```
83+
```js
84+
public outsideValue = "something";
85+
public isMenuItemOutsideValueBound = this.isMenuItemOutsideValue.bind(this);
86+
public isMenuItemOutsideValue(item: any): boolean {
87+
return item.type === this.outsideValue;
88+
}
89+
```
90+
7691
## Multiple Context Menus
7792
You can use multiple context menus in the same component if you would like.
7893

@@ -116,7 +131,7 @@ export class MyContextMenuClass {
116131
public items = [
117132
{ name: 'John', otherProperty: 'Foo' },
118133
{ name: 'Joe', otherProperty: 'Bar' }
119-
};
134+
];
120135

121136
constructor(private contextMenuService: ContextMenuService) {}
122137

@@ -227,7 +242,7 @@ export class MyContextMenuClass {
227242
public items = [
228243
{ name: 'John', otherProperty: 'Foo' },
229244
{ name: 'Joe', otherProperty: 'Bar' }
230-
};
245+
];
231246

232247
constructor(private contextMenuService: ContextMenuService) {}
233248

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular2-contextmenu",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"description": "An Angular 2 component to show a context menu on an arbitrary component",
55
"main": "angular2-contextmenu.js",
66
"scripts": {

src/contextMenu.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export class ContextMenuComponent implements AfterContentInit {
6262
@Optional()
6363
@Inject(CONTEXT_MENU_OPTIONS) private options: IContextMenuOptions
6464
) {
65-
console.log(options);
6665
if (options) {
6766
this.useBootstrap4 = options.useBootstrap4;
6867
}

0 commit comments

Comments
 (0)