Thanks, Lauren Camtreher, it worked.
Your code is the only one that also triggers a state change in the area.
Only configured so that if you click on popover, the latter will close.
I mixed your code and now it also works if you click inside a popover.
Regardless of whether the system runs through popover-template,
To make it recognizable with a popover-template popup window, I used the popover-body and popover-title classes corresponding to the header and body of the popover created using the template and making sure that it points directly to them in the code:
angular.element(document.body).bind('click', function (e) { var popups = document.querySelectorAll('.popover'); if(popups) { for(var i=0; i<popups.length; i++) { var popup = popups[i]; var popupElement = angular.element(popup); var content; var arrow; if(popupElement.next()) {
Ever had a good day, thanks Lauren, thanks AngularJS, thanks so many stack families!
Updated:
I updated all adding an additional control. Elements inside the popover were excluded from control (for example, the image inserted into the body of the popover.). Then click on the same closed.
I used the Node.contains API command integrated into a function that returns true or false.
Now, with any element placed inside, start the control and save the postcard if you click inside:
// function for checkparent with Node.contains function check(parentNode, childNode) { if('contains' in parentNode) { return parentNode.contains(childNode); } else { return parentNode.compareDocumentPosition(childNode) % 16; }} angular.element(document.body).bind('click', function (e) { var popups = document.querySelectorAll('.popover'); if(popups) { for(var i=0; i<popups.length; i++) { var popup = popups[i]; var popupElement = angular.element(popup); var content; var arrow; if(popupElement.next()) { //The following is the content child in the popovers first sibling // For the classic popover with Angularjs Ui Bootstrap content = popupElement[0].querySelector('.popover-content'); // For the templating popover (popover-template attrib) with Angularjs Ui Bootstrap bodytempl = popupElement[0].querySelector('.popover-body'); headertempl= popupElement[0].querySelector('.popover-title'); //The following is the arrow child in the popovers first sibling // For both cases. arrow = popupElement[0].querySelector('.arrow'); } var checkel= check(content,e.target); if(popupElement[0].previousSibling!=e.target && e.target != content && e.target != arrow && e.target != bodytempl && e.target != headertempl&& checkel == false){ popupElement.scope().$parent.isOpen=false; popupElement.remove(); } } } });