title: How to make controller in angular main layout run on route change?
body: <p>I have an angular page that has an ng-controller directive and an ng-view directive.</p>
  
  <pre><code>&lt;body ng-controller="MainController"&gt;
     &lt;h1&gt;Welcome to my main template&lt;/h1
     &lt;ng-view&gt;&lt;/ng-view&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I also have routes configured. </p>
  
  <pre><code>angular.module('app', []).
      config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
          $routeProvider.
              when('/', {templateUrl: '/templates/home.html', controller: HomeController}).
              when('/start', {templateUrl: '/templates/start.html', controller: StartController});
  
          $locationProvider.html5Mode(true);
  }]);
  </code></pre>
  
  <p>When I click a URL that routes me to /start for example, only StartController runs, not MainController. I guess this kind of makes sense since the main layout has already loaded, and then the template only needs to be loaded now, but there is logic in my MainController that controls part of the template view I need to run.</p>
  
  <p>However, if I refresh the entire page, both controllers run.</p>
  
  <p>Is there any way to make both controllers run? Is this the wrong pattern to follow?</p>