title: Angular sub-views
body: <p>I google a bit about the topic but I couldn't get a clear answer on the subject, so apologies if this seems a pretty beaten down question. I've started with Angular not long ago, and I really want to be on the good path.</p>
  
  <p>The application is bootstraped by <code>app.js</code> which defines the routes in the configuration. The <code>index.html</code> has a body with a <code>ng-app</code> directive an just a div inside with a <code>ng-view</code>.</p>
  
  <pre><code>  $routeProvider
      .when('/', {
        templateUrl: 'views/main.html',
        controller: 'MainController'
      })
      .otherwise({
        redirectTo: '/'
      });
  </code></pre>
  
  <p>This <code>main.html</code> and controller are the bulk of the app, which is quite simple.</p>
  
  <p>Now I wanted to have a header, which either shows Login or the information from the user. I though that should be another Controller and another View, since the header should encapsulate all that code instead of polluting the main view.</p>
  
  <p>What should I do? </p>
  
  <ol>
  <li><p>I could remove the <code>ng-app</code> and create two different controllers for the header and the main app, but then I don't know how to associate each view to each <code>ng-controller</code> like the <code>routeProvider</code> is doing, although if I don't mind writing all the html inline, this should work. I would also lose routing which I don't really want to.</p></li>
  <li><p>I could just create a <code>ng-controller=headerController</code> inside the app and still have the code inline. Is there an option to associate a template with a controller without the route definition?</p></li>
  </ol>
  
  <p>What I'm currently going to do until I have a better option is to add all of this logic to the mainController. I just feel that I'm building big blocks instead of small ones that I can just  compose. Imagine I do three more routes that need a header. Using option 1) or 2) I would have to write the template html for the header again in those views.</p>
  
  <p>I would appreciate any links or help for this matter, I'm really curious how to approach this in a module fashion.</p>
  
  <p>Thank you in advance.</p>