I'm not sure if I understand your goal 100%, but the plunker has been updated to show how we can work with nested views.
Firstly, there is $ state uncertainty showing nesting:
$stateProvider .state('index', { url: '/', views: { '@' : { templateUrl: 'layout.html', controller: 'IndexCtrl' }, 'top@index' : { templateUrl: 'tpl.top.html',}, 'left@index' : { templateUrl: 'tpl.left.html',}, 'main@index' : { templateUrl: 'tpl.main.html',}, }, }) .state('index.list', { url: '/list', templateUrl: 'list.html', controller: 'ListCtrl' }) .state('index.list.detail', { url: '/:id', views: { 'detail@index' : { templateUrl: 'detail.html', controller: 'DetailCtrl' }, }, })
And here is the layout.html main index layout.html :
<div> <section class="top"> <div ui-view="top"></div> </section> <section class="middle"> <section class="left"> <div ui-view="left"></div> </section> <section class="main"> <div ui-view="main"></div> </section> </section> </div>
And how does it work?
I. View List
we can see the contents of tpl.top.html
<div> This is a tpl.top.html<br /> <a ui-sref="index">index</a> <a ui-sref="index.list">index.list</a><br /> </div>
which has some navigation to the representation of an index list or . The list view will be entered into the tpl.left.html file, which looks like this:
<div> This is a tpl.left.html <h4>place for list</h4> <div ui-view=""></div> </div>
Eliminating the view target is not called <div ui-view=""></div> , we can define the $ state list as follows:
.state('index.list', { url: '/list', templateUrl: 'list.html', controller: 'ListCtrl' })
we see that we aim the anchor of the view state (root), which is not called. But for the details we use a different technique:
II. Detailed view
This is the content of tpl.main.html:
<div> This is a tpl.main.html <h4>place for detail</h4> <div ui-view="detail"></div> </div>
In this case, the anchor for the view is named: ui-view = "detail", so we must define this detailed state as follows:
.state('index.list.detail', { url: '/:id', views: { 'detail@index' : { templateUrl: 'detail.html', controller: 'DetailCtrl' }, }, })
We can see that since the parent view is not an object of our state (the parent index is the target) , we must use aboslute naming: 'detail@index'
III. Browse Names - Relative and Absolute Names
small cite from doc:
Behind the scenes, each view is given an absolute name that follows the viewname@statename , where viewname is the name used in the view directive, and the state name is the absolute state name, for example. contact.item. You can also write name names in absolute syntax.
SUMMARY:
So, this example is about almost all the essential features of ui-router . We showed here how to use the nested representation of names (absolute / relative), as well as how to use multiple views for one state (determining the state of the index)
Please note that everything is in action here (click inex.html in the upper section, then try to select some details)