import { Component , ViewEncapsulation } from '@angular/core' ; import { ContextOpenEvent } from '../../../ng2-right-click-menu/src/lib/sh-attach-menu.directive' ; @ Component ( { selector : 'app-root' , encapsulation : ViewEncapsulation . None , templateUrl : './app.component.html' , styleUrls : [ './app.component.css' ] } ) export class AppComponent { title = 'Right Click Me' ; items : any [ ] ; thisContext = this ; itemVisible = false ; constructor ( ) { this . items = [ { label : 'Item One' } , { label : 'Item Two' } ] ; } onOpen ( event ) { if ( event . data . label === 'Item One' ) { event . preventOpen ( ) ; } } onClick ( event ) { console . log ( 'clicked' , this , event ) ; } isVisible ( event ) { return true ; } }