4

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

1

2 Answers 2

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>
Sign up to request clarification or add additional context in comments.

6 Comments

That's a great suggestion and I'll make sure to try it!
Great - if you think it's the right answer could you mark it please.
I updated my plunkr in case anyone wants to see your suggestion in action.
Arrg, I can't get the ng-include="footer" to work and I'm not sure why. I'm not getting any errors.
Sorry I'm un-"answering" this even though you offered a suggestion as I initially asked. I'm hoping I can get someone to help me actually make this work.
|
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.

1 Comment

This will make all your states children of root. For navigation you will have to use 'root.<statename>' for navigation

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.