I'm really struggling to implement stopPropagation. I'm currently working with multiple drop down menus. I would like to set it up so that when you open a menu, then click anywhere outside of it, the menu toggles off. Ideally only one menu should be open at a time, so when you open one and then click on another, the first toggles off.
Perhaps I'm approaching this in a way that is completely wrong. If so, I'd appreciate a nod in the correct direction!
Thanks!
Here is how I'm handling the open and close of the drop menus:
<a ng-click="popout.isVisible = !popout.isVisible">Drop Menu #1</a>
<ul ng-show="popout.isVisible">
    <li>This is some text.</li>
    <li>This is some text.</li>
    <li>This is some text.</li>
</ul>
<a ng-click="popout.isVisible = !popout.isVisible">Drop Menu #2</a>
<ul ng-show="popout.isVisible">
    <li>This is some text.</li>
    <li>This is some text.</li>
    <li>This is some text.</li>
</ul>
Here is some code that I found that creates a stopEvent directive, but isn't working quite the way that I need:
myApp.directive('stopEvent', function () {
  return {
    link: function (scope, element, attr) {
      element.bind(attr.stopEvent, function (e) {
          e.stopPropagation();
          alert('ALERT!');
      });
    }
  };
});
 
    