我是ui-router的新用户,无法layout.directory.teams
或layout.directory.people
加载各自的模板。我希望这些模板可以加载到ui-view
州模板上的layout
。
/dashboard
工作正常...... dashboard.html
模板已加载到ui-view
content.html
模板中。
/directory/teams
无法加载teams.html
模板。
/directory/people
未加载people.html
模板。
.state('layout', {
abstract: true,
templateUrl: "components/common/content.html"
})
.state('layout.dashboard', {
url: "/dashboard",
controller: 'DashboardCtrl',
controllerAs: 'dashboard',
templateUrl: "app/features/dashboard/views/dashboard.html",
})
.state('layout.directory', {
abstract: true,
url: "/directory"
})
.state('layout.directory.teams', {
url: "/teams",
controller: 'DirectoryCtrl',
controllerAs: 'directory',
templateUrl: "app/features/directory/views/teams.html",
})
.state('layout.directory.people', {
url: "/people",
controller: 'DirectoryCtrl',
controllerAs: 'directory',
templateUrl: "app/features/directory/views/people.html",
})
答案 0 :(得分:5)
子状态在其父级的模板中呈现其模板ui-view
指令,即使父级是abstract
。
因此,在您的情况下,将ui-view
添加到layout.directory
州的模板中:
.state('layout.directory', {
abstract: true,
url: "/directory",
template: "<div ui-view></div>"
})