import { Component , OnInit , Input , Output , EventEmitter , ElementRef , OnChanges } from '@angular/core' ; @ Component ( { selector : 'app-popup' , templateUrl : './popup.component.html' , styleUrls : [ './popup.component.scss' ] , host : { '(document:click)' : 'onClickGlobal($event)' } } ) export class PopupComponent { constructor ( private elRef ) { } private _show ; @ Input ( ) optionsList = [ ] ; @ Output ( ) showChange = new EventEmitter ( ) ; @ Input ( ) set show ( show ) { this . _show = show ; this . showChange . emit ( this . _show ) ; } get show ( ) { return this . _show ; } onClickGlobal ( $event ) { if ( ! this . elRef . nativeElement . contains ( $event . target ) ) { this . show = false ; } } selectListItem ( listItem ) { listItem . action ( ) ; this . show = false ; } }