嗨,我有一个页面,其中注入了嵌套视图,我正在使用状态。问题是我有一个场景,点击按钮时我想显示页面的某个部分,或者你可以说那个超链接。但我很困惑如何准确地转到那个嵌套视图。我做了一些这样的事情。
<a href="username#media">More media</a>
但它并不总是有效,有时它会显示确切的部分,但有时它的位置有点向下。
这是我的路线文件。
.state('profile', {
url: '/:artist_name?jobId',
params: {
artist_id: null,
jobId: {value: null, squash: true},
openRepertoire: {value: false, squash: true}
},
views: {
'': {
templateUrl: 'views/profile/artistprofile.main.view.html',
controller: 'ArtistProfileMainController',
controllerAs: 'profile',
}, 'basicInfo@profile': {
templateUrl: 'views/profile/basicInfo.view.html',
controller: 'ArtistProfileBasicInfoController',
controllerAs: 'basicInfo',
}, 'header@profile': {
templateUrl: 'views/profile/header.view.html',
controller: 'ArtistProfileHeaderController',
controllerAs: 'header',
}, 'quotes@profile': {
templateUrl: 'views/profile/quotes.view.html',
controller: 'ArtistProfileQuotesController',
controllerAs: 'quotes',
}, 'schedule@profile': {
templateUrl: 'views/profile/schedule.view.html',
controller: 'ArtistProfileScheduleController',
controllerAs: 'schedule',
}, 'media@profile': {
templateUrl: 'views/profile/media.view.html',
controller: 'ArtistProfileMediaController',
controllerAs: 'media',
}, resolve: {
$title: getUserProfile,
user: isLogin
}
})
现在单击时,我想转到media
注入视图的页面部分。我anchorscroll
也用过。但结果并不总是 100% 完美。有时它会打开页面并显示媒体部分,有时则不会。