While there is no plunker showing your example, I will share one with you: working layout example. Please observe it to see in action what I will try to explain here
If our root
state should be the only root state, injected into index.html
, we do need a bit different defintion:
So for index.html
// index.html
<body>
<div ui-view="layout">
</div>
</body>
we would need this syntax:
$stateProvider
.state('root', {
url: '',
views: {
'layout': {
templateUrl: 'partials/layout/1-column.html'
},
'header@root': {
templateUrl: 'partials/layout/sections/header.html'
},
'footer@root': {
templateUrl: 'partials/layout/sections/footer.html'
}
}
})
What is this: 'header@root'
? it is absolute naming. Check it here:
- View Names – Relative vs. Absolute Names (small cite below)
- and here I tried to expain that in detail
Behind the scenes, every view gets assigned an absolute name that follows a scheme of
'viewname@statename'
, where viewname is the name used in the view directive and state name is the state’s absolute name, e.g. contact.item. You can also choose to write your view names in the absolute syntax.
The same goes for other states definitions. Because the ‘root.signup’ has direct parent ‘root’, the existing syntax would be working
.state('root.signup', {
url: '/signup',
views: {
'step-breadcrumb': { // working AS IS
...
But we could use absolute naming and it would work as well
.state('root.signup', {
url: '/signup',
views: {
'step-breadcrumb@root': { // absolute naming
...
because this is how it works behind anyway.
Please, observe the layout example for more details