我们可以在 一种* 状态下使用 更多 视图,请参阅: *
- 多个命名视图
该定义只需要使用绝对命名即可:
.state('state1', { url: '/', views: { 'main': { templateUrl: '/modules/blog/partials/index.html', controller: 'BlogController' }, // instead of // 'sidebar': { // we need 'sidebar@state1': { templateUrl: '/modules/core/partials/sidebar.html' } }});如此处详细说明:
- 视图名称-相对名称与绝对名称
在幕后,每个视图都被分配一个遵循方案的绝对名称
viewname@statename
,其中viewname是view指令中使用的名称,状态名称是该状态的绝对名称,例如contact.item。您还可以选择以绝对语法编写视图名称。
因此,如上面的代码段所示,如果
/modules/blog/partials/index.html
将是:
<div> <!-- content populated here by AngularJS ui-router --> <aside ui-view="sidebar"> <!-- content populated here by AngularJS ui-router --> </aside></div>
并且index.html将包含占位符:
<div ui-view="main" ></div>
然后
'main'
-将在父根目录(index.html)中搜索'sidebar@state1'
将被评估为“ state1”(本身)中的viewName / target
一个
有类似想法的示例,后面有一些layout.html。



