I'm working on an Angular 7 app. I added an icon that the user can click on, and when they click on it, an absolutely positioned div appears like a tooltip. The tooltip is encapsulated in an Angular component.
I need to make the tooltip disappear when the user clicks anywhere on the page outside of the tooltip. It seems that I need to somehow add a universal event handler on the whole page that catches mouse clicks and somehow checks to see if the tooltip is open and whether or not the click event was on the tooltip, but I do not know how to do this within the component model of Angular.
How do I make it so that when the user clicks on the page outside of the tooltip, the tooltip disappears?
I should add that I can't simply add an invisible div that covers the page behind the tooltip and listen for clicks on that because then the user wouldn't be able to click on other page elements.