javascript - How to close a `div` box in Angular when I click outside When do you use in the accusative case? By clicking Accept all cookies, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy. If you not like the over layer you can set opacity = 0. Why don't we use the 7805 for car phone chargers? When are you supposed to use escape instead of encodeURI / encodeURIComponent? When I click somewhere else, dropdown does not close. Episode about a group who book passage on a space ship controlled by an AI, who turns out to be a human who can't leave his ship? here is the Fiddle, i want to close menu with any click outside the parent div . Which was the first Sci-Fi story to predict obnoxious "robo calls"? Read the answer again. Why does Acts not mention the deaths of Peter and Paul? If we had a video livestream of a clock being sent to Mars, what would we see? Ubuntu won't accept my choice of password. I've just attached document:click on my toggle function as follow : So, when I am outside my directive, I close the dropdown. Which was the first Sci-Fi story to predict obnoxious "robo calls"? Connect and share knowledge within a single location that is structured and easy to search. Could you possibly explain further? Disable click outside of angular material dialog area to close the dialog (With Angular Version 4.0+). This wont work if you want to keep the dropdown open on click, for example a user might miss click a button. My Open method is as follows: This is a simplified version, that doesn't need call the whole toggleSearch() function again and prevents the double $apply(). The drawer is not closing because the click event occurs outside the digest cycle and Angular doesn't know that $scope.open has changed. Why did DOS-based Windows require HIMEM.SYS to boot? To learn more, see our tips on writing great answers.