title: How to hide Bootstrap navbar drop-down menu when any link is clicked in an Angular app?
body: <p>On narrow screens, the Bootstrap navbar is presented as a panel of buttons that overlay the page content. There are many questions and answers addressing problems getting that panel to be hidden when it is clicked on - that is not the problem I am trying to solve.</p>
  
  <p>This question is how to get that panel to be hidden when links in the main body of the page are clicked <strong>and</strong> when those links are produced by AngularJs templates. Is there a simple solution?</p>
  
  <p>Here is the relevant content of the main page into which Angular inserts content:</p>
  
  <pre><code>&lt;html lang="en" xmlns:ng="http://angularjs.org" id="ng-app" ng-app="eepApp"
          ng-controller="AppController"&gt;
  &lt;head&gt;
  ...
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;!-- Small screen menu --&gt;
  &lt;div class="navbar navbar-default navbar-fixed-top visible-xs" role="navigation"&gt;
      &lt;div class="container-fluid"&gt;
          &lt;div class="navbar-header"&gt;
              &lt;button type="button" class="navbar-toggle" data-toggle="collapse"
                      data-target="#navbar-collapse-id"&gt;
                  &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
                  &lt;span class="icon-bar"&gt;&lt;/span&gt;
                  &lt;span class="icon-bar"&gt;&lt;/span&gt;
                  &lt;span class="icon-bar"&gt;&lt;/span&gt;
              &lt;/button&gt;
              &lt;ul class="nav navbar-nav navbar-left pull-left"&gt;
                  ...
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="collapse navbar-collapse" id="navbar-collapse-id"&gt;
              &lt;ul class="nav navbar-nav navbar-right"&gt;
                  ...
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;!--  Bigger screen menu --&gt;
  &lt;div class="navbar navbar-default navbar-fixed-top hidden-xs" role="navigation"&gt;
      ...
  &lt;/div&gt;
  
  &lt;!--  Page content inserted by Angular here --&gt;
  &lt;div id="partials" ng-view="partials"&gt;&lt;/div&gt;
  
  &lt;script src="various JavaScript inculding Angular and jQuery"/&gt;
  
  &lt;script&gt;
  
  // Hide navbar menu when item clicked
  $(document).on('click', '.navbar-collapse.in', function(e) {
      if ($(e.target).is('a') || $(e.target).parent().is('a')) {
          $(this).collapse('hide');
      }
  });
  
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>