Matthew James Davis
Matthew James Davis

Reputation: 12295

AngularJS, Persistent (header) controller and specific (body) controller in one app

I am developing an HTML 5 mobile angular app with an android style skin. The app will need to be login-aware and I'm looking for advice on best practices. What I need is:

  1. To have a persistent header that will display the current view, change the current view (via a dropdown), and perform login-specific functions (like "view my stuff" or "logout")
  2. To have several different views within the app such as "master view" and "detail view" and "map view"
  3. To have the app display a particular view (login.html) when the user is not logged in.

It seems like 3 is a special case of 1. In any case, the header is persistent throughout the app (except when a user isn't logged in) and the views will change based on user input. What is the best way to tackle this style of application using angular?

Upvotes: 1

Views: 791

Answers (1)

Ven
Ven

Reputation: 19040

I think you want to use ngInclude.

I think you're already using ng-view for your body. Makes things easy :

<body>
  <div id="header" ng-include="'header.html'"></div>
  <div id="container" ng-view></div>
</body>

Upvotes: 1

Related Questions