我正在使用ui-roter。我有两组页面。组A和组B.在每组中,重复header
和footer
但是content
改变。我怎么能不重复每个组的页眉和页脚?有没有办法让代码更简单?尝试一个变量,但它不适合我。ui-view AngularJs多视图
我的index.html
<div ui-view="header"></div>
<div ui-view="content"></div>
<div ui-view="footer"></div>
甲组
$stateProvider
.state('inicio', {
url: '/inicio',
views: {
'header': {templateUrl: 'views/header.html'},
'content': {templateUrl: 'views/inicio.html'},
'footer': {templateUrl: 'views/footer.html'}
}
});
$stateProvider
.state('seguroPersonas', {
url: '/seguroPersonas',
views: {
'header': {templateUrl: 'views/header.html'},
'content': {templateUrl: 'views/seguroPersonas.html'},
'footer': {templateUrl: 'views/footer.html'}
}
});
$stateProvider
.state('seguroEmpresas', {
url: '/seguroEmpresas',
views: {
'header': {templateUrl: 'views/header.html'},
'content': {templateUrl: 'views/seguroEmpresas.html'},
'footer': {templateUrl: 'views/footer.html'}
}
});
B组
$stateProvider
.state('dashboard', {
url: '/dashboard',
views: {
'header': {templateUrl: 'views/dashboard/headerDashboard.html'},
'content': {templateUrl: 'views/dashboard/inicioDashboard.html'},
'footer': {templateUrl: 'views/dashboard/footerDashboard.html'}
}
});
$stateProvider
.state('clientesPotenciales', {
url: '/dashboard/clientesPotenciales',
views: {
'header': {templateUrl: 'views/dashboard/headerDashboard.html'},
'content': {templateUrl: 'views/dashboard/clientesPotenciales.html'},
'footer': {templateUrl: 'views/dashboard/footerDashboard.html'}
}
});
$stateProvider
.state('seguroEmpresas', {
url: '/seguroEmpresas',
views: {
'header': {templateUrl: 'views/dashboard/headerDashboard.html'},
'content': {templateUrl: 'views/dashboard/actualizacionDatos.html'},
'footer': {templateUrl: 'views/dashboard/footerDashboard.html'}
}
});
遗憾的无知,我要创建的文件夹'路径/ to'? 'path/to/a.html' –
'path/to'指示任何路径包含组A/B模板的新文件。因此,如果您将新文件'a.html'放入'views'目录中,路径将为:'views/a.html'。 – pkowalcze
好的,我很清楚pata/to。我试过了,但它不起作用。将有事做'a.inicio'这是从哪里来的?我应该事先命名吗? –