GitXplorerGitXplorer
t

angular-click-outside

public
5 stars
3 forks
1 issues

Commits

List of commits on branch master.
Unverified
edbe5c72837673e99a8cd6daf82ae8946af1fbdf

Merge pull request #6 from tobiasbueschel/patch-2

ttwhitbeck committed 7 years ago
Unverified
cdb479c2e49e1b634ba4fb8fa9f20b5f60891d0f

Merge pull request #5 from tobiasbueschel/patch-1

ttwhitbeck committed 7 years ago
Unverified
836cfa5cbca0e2257ed58fffca6a2a2d4a592e60

Add MIT license

ttobiasbueschel committed 7 years ago
Unverified
cef2cffc68c835b68733e1c8c9d302daf1c186cc

Create LICENSE.md

ttobiasbueschel committed 7 years ago
Unverified
08247e3ae6fe4e3a20d6d22f3336ed2369ee21c5

1.2.0

ttwhitbeck committed 8 years ago
Unverified
6fc250168c4c6b8ecf778a3ef3620702295cf905

Update example

ttwhitbeck committed 8 years ago

README

The README file for this repository.

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