Socket
Socket
Sign inDemoInstall

angular-click-outside-2

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    angular-click-outside-2

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


Version published
Maintainers
1
Install size
4.96 kB
Created

Readme

Source

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
<script src="node_modules/angular-click-outside/angular-click-outside.js"></script>
  • Add the tw.directives.clickOutside module to your module's list of dependencies:
angular.module('app', ['tw.directives.clickOutside'])
  • Use the twClickOutside directive.
<div class="menu" tw-click-outside="hideMenu()">
...
</div>
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:

<button ng-click="showMenu()">Show Menu</button>
<div class="menu" tw-click-outside="hideMenu()" ignore-if="menuAlreadyHidden()">
...
</div>

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

FAQs

Last updated on 18 Jul 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc