【发布时间】:2021-12-09 02:07:04
【问题描述】:
所以我目前正在使用离子和角度。我使用 ion-segment(艺术家和场地)在单个页面上显示 2 种不同类型的用户。两个用户的信息都按照我想要的方式显示在卡片上。当我点击艺术家个人资料时,它正在显示,但是当我点击场地用户时,它正在显示来自艺术家的 HTML 而没有数据。 场地配置文件的 id 是正确的,只是当它被带到配置文件时,它没有按我想要的方式工作。我觉得问题可能出在应用程序路由中?但我不确定,因为我已尝试更改它,但仍然无法正常工作。
discover.page.html:
<ion-card
*ngFor="let venue of relevantVenue.slice(1)"
fill="clear"
[routerLink]="['/','tabs','tab1','discover',venue.id]"
>
场地详情:
ngOnInit() {
this.route.paramMap.subscribe(paramMap => {
if (!paramMap.has('venueId')) {
this.navCtrl.navigateBack('/tabs/tab1/discover');
return;
}
this.venueSub = this.venueService
.getVenue(paramMap.get('venueId'))
.subscribe(venue => {
this.loadedVenue = venue;
});
});
}
ngOnDestroy() {
if (this.venueSub) {
this.venueSub.unsubscribe();
}
}
tabs-routing.module.ts:
const routes: Routes = [
{
path: '',
component: TabsPage,
children: [
{
path: 'tab1',
children: [
{
path: '',
loadChildren: () => import('../tab1/tab1.module').then(m => m.Tab1PageModule)
},
{
path: 'discover/:artistId',
loadChildren: () => import('../tab1/discover/artist-details/artist-details.module').then(m => m.ArtistDetailsPageModule)
},
{
path: 'discover/:venueId',
loadChildren: () => import('../tab1/discover/venue-details/venue-details.module').then(m => m.VenueDetailsPageModule)
}
]
},
【问题讨论】:
标签: ionic-framework routes ionic2 angular-routing