Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/NetanelBasal/ngx-event-modifiers

Event Modifiers for Angular Applications https://netbasal.com/implementing-event-modifiers-in-angular-87e1a07969ce
https://github.com/NetanelBasal/ngx-event-modifiers

angular2 dom events preventdefault stoppropagation

Last synced: 3 months ago
JSON representation

Event Modifiers for Angular Applications https://netbasal.com/implementing-event-modifiers-in-angular-87e1a07969ce

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/NetanelBasal/ngx-event-modifiers.svg?branch=master)](https://travis-ci.org/NetanelBasal/ngx-event-modifiers)
## Event Modifiers for Angular Applications (inspired by Vue)

### Installation

To install this library, run:

```bash
$ npm install ngx-event-modifiers --save
```
```typescript
import { EventModifiersModule } from 'ngx-event-modifiers';

@NgModule({
imports: [
EventModifiersModule
]
})
export class AppModule { }
```

### Usage
- `(click.stop)` - The click event's propagation will be stopped
```html
Click Me!!
```
- `(click.prevent)` - The submit event will no longer reload the page
```html
Click Me!!
```
- `(click.self)` - Only trigger handler if event.target is the element itself i.e. not from a child element
```html


Click Me!!

```
- `(click.once)` - The click event will be triggered at most once
```html
Click Me!!
```
- `(click.outside)` - The click event will be triggered only if clicked outside the current element
```html

Click Me!!

```
You can also pass `[eventOptions]`:
```html

Click Me!!

```
## License

MIT © [Netanel Basal](mailto:[email protected])