I'm trying to build from scratch a very simple angular app using ui-router.
Every page will have the same appearance, and will have the following 4 sections (vertically, from top to bottom):
- HEADER (common to all pages)
- HORIZONTAL MENU (common to all pages)
- CONTENT (this is the only content that will change)
- FOOTER (common to all pages)
My index.html
has <div ui-view></div>
inside the <body>
tag.
I also have a simple html file (portal.html
) that contains the structure of every page:
<div ui-view="header"></div>
<div ui-view="menu"></div>
<div ui-view="content"></div>
<div ui-view="footer"></div>
I've have created a parent state, where I set the common sections to every page:
$stateProvider
.state('portal', {
url: '/portal',
templateUrl: 'app/main/portal.html',
views: {
header: {
templateUrl: 'app/main/section/header.html'
},
menu: {
templateUrl: 'app/main/section/menu.html'
},
footer: {
templateUrl: 'app/main/section/footer.html'
}
}
});
And some child states (one for each menu option - page), where I set the variable content to every page:
$stateProvider
.state('portal.home', {
url: '/home',
views: {
'content@portal': {
controller: 'HomeCtrl as homeVM',
templateUrl: 'app/portal/home.html'
}
},
resolve: { /* whatever */ }
})
// ... and so on ...
.state('portal.contactUs', {
url: '/contact-us',
views: {
'content@portal': {
controller: 'ContactUsCtrl as contactUsVM',
templateUrl: 'app/portal/contactUs.html'
}
},
resolve: { /* whatever */ }
});
But this won't display anything on screen... Am I missing something here?