When it comes to ui.router modules I can think of three different ways to set a default header and footer for every view:
DEFAULT HEADER
<CONTENT>
DEFAULT FOOTER
1. ng-include - attaching your header / footer into your initial .html file (index.html).
<html>
<div ng-include src="'header.html'"></div>
<div id="content" ui-view></div>
1.1. Pasting code into index.html
<html>
<div><!-- my header code here --></div>
<div id="content" ui-view></div>
2. Using directives to parse the header and footer.
home.html
<!-- content -->
<!-- /content -->
<footer></footer>
footerDirective.js
module.directive('footer', function () {
return {
restrict: 'E',
replace: true,
templateUrl: "footer.html",
controller: ['$scope', '$filter', function ($scope, $filter) {
}]
}
});
http://gon.to/2013/03/23/the-right-way-of-coding-angularjs-how-to-organize-a-regular-webapp/
3. Creating an extra state on ui.router with no url.
State wrapper would then contain the header and footer and won't be callable.
$stateProvider
.state('wrapper', {
templateUrl: 'wrapper.html', // contains html of header and footer
controller: 'WrapperCtrl'
})
.state('wrapper.home', {
url: '/',
templateUrl: 'home.html',
controller: 'HomeCtrl'
});
Which one is preferred? Or, is there a more desirable way to do it with Angular 1.x?