title: Reload AngularJS Controller
body: <p>I'm a newbie to angularjs.</p>
  
  <p>My problem is that I have a User Controller for handling Login and Logout. I have also another controller to load a header menu for my site.</p>
  
  <p>If the user logs in to the site my isAuthenticated variable is set to true. If the variable is set to true the header should be change but, so I think the controller must be reloaded to change the header view.</p>
  
  <p>Here the code of my HeaderController:</p>
  
  <pre><code>myapp.controller('HeaderController', ['$scope', '$location', '$window', 'AuthenticationService',  
      function HeaderController($scope, $location, $window, AuthenticationService) {
          $scope.isAuthenticated = AuthenticationService.isAuthenticated;
  
          if (AuthenticationService.isAuthenticated) {
              $scope.user.vorname = $window.sessionStorage.user.vorname;
          }
      }
  ]);
  </code></pre>
  
  <p>Here's the code of my HeaderDirective:</p>
  
  <pre><code>myapp.directive('appHeader', function() {
    return {
      restrict: 'E',
      link: function(scope, element, attrs) {
        if (attrs.isauthenticated == 'false') {
          scope.headerUrl = 'views/header/index.html';
        } else {
          scope.headerUrl = 'views/header/isAuthenticated.html';
        }
      },
      template: '&lt;div ng-include="headerUrl"&gt;&lt;/div&gt;'
    }
  });
  </code></pre>
  
  <p>My index.html:</p>
  
  <pre><code>&lt;div ng-controller="HeaderController"&gt;
    &lt;app-header isauthenticated="{{isAuthenticated}}"&gt;&lt;/app-header&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>How can I reload the controller if the user logs in to the page?</strong></p>
  
  <p>PS: Please excuse my poor pronunciation.</p>