https://github.com/twhitbeck/angular-click-outside
A simple directive to execute code when clicking outside of an element
https://github.com/twhitbeck/angular-click-outside
angular click directive outside
Last synced: 6 months ago
JSON representation
A simple directive to execute code when clicking outside of an element
- Host: GitHub
- URL: https://github.com/twhitbeck/angular-click-outside
- Owner: twhitbeck
- License: mit
- Created: 2014-05-20T21:01:12.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2018-09-24T21:11:16.000Z (over 7 years ago)
- Last Synced: 2024-10-19T19:54:23.743Z (over 1 year ago)
- Topics: angular, click, directive, outside
- Language: HTML
- Size: 10.7 KB
- Stars: 5
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
angular-click-outside
=====================
A simple angular 1.x directive to execute code when clicking outside of an element
### Get it
`npm install angular-click-outside --save`
### Use it
* Include script in your html
```html
```
* Add the `tw.directives.clickOutside` module to your module's list of dependencies:
```js
angular.module('app', ['tw.directives.clickOutside'])
```
* Use the `twClickOutside` directive.
```html
```
#### Ignoring the event
If you don't want the `twClickOutside` to fire under certain circumstances (e.g. you don't need to hide the menu if it's already hidden), use the `ignoreIf` attribute:
```html
Show Menu
```
Use this to:
* avoid side effects of `hideMenu()`
* avoid cost of `hideMenu()` if it is more expensive to run than `menuAlreadyHidden()`
#### Developing/testing
Use `npm install && npm start` to open the example in your browser with live reloading via `browserSync`