http://plnkr.co/edit/hqXGl47EJ0wVaEgoXk3X?p=preview
I'm trying to find the best way to accomplish this. Basically there are several popovers we have in our app, for fuzzy search, additional options, help tips etc etc.
When any of them are open, they need to be closeable if the user clicks anywhere else outside of it, like the body.
vs.togglePopover = function() {
vs.searchPopoverDisplay = vs.searchPopoverDisplay === false ? true: false;
};
The ng-click I have on the body currently:
vs.closePopovers = function() {
PopFactory.hidePopovers();
};
This contacts a factory service which gets the scope of all controllers/directives that have a popover and if they are open, close them.
Of course this then makes the popovers unusable since as soon as you click the button to open the popover, the main app.js controller detects a body click and closes it.
var hidePopovers = function() {
searchPopover = ScopeFactory.getScope('search');
tagsSearchPopover = ScopeFactory.getScope('tagsPopover');
tagsSortPopover = ScopeFactory.getScope('tagsSearch');
tagsPanel = ScopeFactory.getScope('tagsPanel');
// is this popover open?
// if so close it, see the problem?
if (searchPopover.searchPopoverDisplay) {
searchPopover.searchPopoverDisplay = false;
}
if (tagsSearchPopover.tagSearchPopover) {
tagsSearchPopover.tagSearchPopover = false;
}
if (tagsSortPopover.tagsPopoverDisplay) {
tagsSortPopover.tagsPopoverDisplay = false;
}
if (tagsPanel.showingTagSearchInput) {
tagsPanel.showingTagSearchInput = false;
}
};
return {
hidePopovers : hidePopovers
};
How is this feature normally addresses in apps with popovers?