angular-click-outside

A simple angular directive for executing code when clicking outside an element

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
angular-click-outside
511.2.07 years ago7 years agoMinified + gzip package size for angular-click-outside in KB

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