1.0.0 • Published 6 years ago

ng-event-outside v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

ng-event-outside

NPM

Demo

Installation

npm install ng-event-outside

Usage

Add NgEventOutsideModule to your list of module imports:

import { NgEventOutsideModule } from 'ng-event-outside';

@NgModule({
  imports: [
    ...
    NgEventOutsideModule
],
...
})
export class AppModule { }

Use the ngEventOutside directive in your html templates:

  <button (click)="toggleShow()"> Show <button>
  <div ngIf="*show" (ngEventOutside)="onEventOutside($event)"></div>
export class AppComponent {
  toggleShow() {
    this.show = !this.show;
  }
  
  onEventOutside($event) {
    this.show = false;
  }
}

Outputs

namedescription
(ngEventOutside)This event fires when [eventListener] invoked outside.

Inputs

NameTypeDefaultDescription
[excludes]HTMLElement[][]An array of excluded elements.
[eventListener]string'click'A String that specifies the name of the HTML DOM event.