在应用程序中,我将视图命名为 mainContent 。
<div class = "wrapper"
ui-view = "mainContent">
</div>
此视图只有一条路线。
$stateProvider
.state("home",
{
url: "/home",
views: {
'mainContent': {
templateUrl: "app/home/home.html"
}
}
});
我将home.html加载到命名视图mainContent视图,该视图也命名为view appContent 。
home.html的
<div class = "row"
ui-view = "appContent">
</div>
嵌套的命名视图appContent的路由就在这里。
$stateProvider
.state("request",
{
parent: "home",
abstract: true,
url: "/request"
})
.state("request.create", {
url: "/create",
views: {
appContent: {
templateUrl: "app/requests/create/createRequest.html",
controller: "RequestController as vm"
}
}
});
当我尝试加载 http://.../#/home/request/create 时,未创建RequestController,也未加载视图createRequest.html。
从视图导航到request.create状态:
<a ui-sref = "request.create"><i class = "fa fa-plus"></i>New</a>
感谢
答案 0 :(得分:0)
您的“请求”状态需要自己的模板和ui视图,您可以在其中打开其子视图
$stateProvider
.state("home",
{
url: "/home",
views: {
'mainContent': {
template: "<div class ='row' ui-view ='appContent'></div>"
}
}
})
.state("request",
{
parent: "home",
abstract: true,
url: "/request",
views: {
'appContent': {
template: "<div class ='row' ui-view ='requestContent'></div>"
}
}
})
.state("request.create", {
url: "/create",
views: {
'requestContent': {
template: "<p>Create Request</p>"
}
}
});
这对我有用。证明:http://jsfiddle.net/eD3MU/373/