我有一个非常简单的 appConfig:
var home = {
name: 'home',
url: '/home/'
};
var homeAccess = {
name: 'home.access',
url: 'access',
views: {
'home': {
templateUrl: 'app/access/partials/webapi.html'
}
}
};
在我的 index.html 中有这段代码:
<div ui-view="home">home view here</div>
但是当我导航到主页/访问时,我看到的只是“主页 View ”字样
谁能看到我的访问页面不显示可能做错了什么。
最佳答案
根 stat home,期待 unnamed View 目标 - 所以 index.html 应该包含它
//<div ui-view="home">home view here</div>
<div ui-view="">home view here</div>
home 状态现在应该包含其子级的目标
var home = {
name: 'home',
url: '/home/',
template: '<div ui-view="home">home view here</div>'
};
或者我们可以在我们的 home.access 状态中定位 Root View ,像这样 '@home':
var homeAccess = {
name: 'home.access',
url: 'access',
views: {
//'home': {
'home@': {
templateUrl: 'app/access/partials/webapi.html'
}
}
};
在此处查看类似内容:Angular UI Router - Nested States with multiple layouts
关于AngularJS ui-router View 没有显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35507141/