Enigma
Enigma

Reputation: 859

Click-away event in AngularJS

I've two Div's on my page. one is parent div, another div as pop-up. Currently pop-up is shown/hide on click of parent div or clicking on button inside pop-up window.

How can I achieve that pop-up will be closed when I click away (anywhere outside pop-up and parent div) ? is there any event mechanism already provided ? if yes, How to use it?

Upvotes: 0

Views: 206

Answers (1)

Edison Biba
Edison Biba

Reputation: 4423

You can create another div with full width and height and z-index bigger that other content and less than pop up. Show that div whenever the pop up is showed. Then you can add this div an click event so when the user click on that div it means that it's outside of pop up.

Here is an jsfiddle for that made with jquery just to give you the idea how to make it . Here is another one with Angular DEMO

Upvotes: 1

Related Questions