3

Sorry if the title of this is confusing.

I'm converting a template I purchased into an angular.js app.

I want to use different modules to organize the app.

I'm also using version 0.2.5 of angular-ui-router which allows routing with separate modules.

All is well except the template I'm using looks like this:

<div>Global Nav Bar</div>
<div>Content that changes with different states right below Nav Bar</div>
<div class="wrapsContentAndPushesToBottom">
  <div>Content that changes with different states at 
       bottom of page thanks to parent div's class</div>
  <div>Global Footer also on bottom of page due 
       to parent div's class</div>
</div>

I'm having a hard time getting that global footer to work because of that parent wrapping div.

Can someone help me get this to work?

UPDATE:

I can't get suggested ng-include to work with my plunkr example: http://plnkr.co/edit/dgNkHX

I also can't it working using a named view for the footer: http://plnkr.co/edit/BO8NDO

Julia Anne Jacobs
  • 508
  • 1
  • 4
  • 20
  • possible duplicate of [Angular UI-Router How to create a "layout" state?](http://stackoverflow.com/questions/22104893/angular-ui-router-how-to-create-a-layout-state) – AncientSwordRage Mar 25 '15 at 12:05

2 Answers2

2

I think you're looking for ng-include. http://docs.angularjs.org/api/ng.directive:ngInclude

That will enable you to extract that global footer out to a separate file and just include it in your template.

<div ng-include src="'globalFooter.tpl.html'"></div>
eddiec
  • 7,608
  • 5
  • 34
  • 36
2

Try something like this:

.state('root', {
  abstract: true,
  views: {
    '@': {

    },
    'sideBar@': { templateUrl: 'views/sidebar.html', controller: 'SideBarCtrl' },
    'header@': { templateUrl: 'views/header.html' },
    'footer@': { templateUrl: 'views/footer.html' }
  }
})

.state('main', {
  url: '/',
  parent: 'root',
  views: {
    '@': { templateUrl: 'views/main_content.html', controller: 'MainCtrl' }
  }
})

This is working for me.. I have a global footer.

Rodrigo Reis
  • 1,891
  • 1
  • 11
  • 12