У меня есть макет с 5 вкладками.Когда я перехожу на вторую вкладку и затем на подстраницу, возвращаясь назад с ion-back-button
, вы попадаете на первую вкладку.Как я могу вернуться к последней выбранной вкладке?
Любая помощь высоко ценится!
const routes: Routes = [
{ path: '', loadChildren: './tabs/tabs.module#TabsPageModule' },
{ path: 'home', loadChildren: './home/home.module#HomePageModule' },
{ path: 'timetable', loadChildren: './timetable/timetable.module#TimetablePageModule' },
{ path: 'artistDetail/:id', loadChildren: './artist-detail/artist-detail.module#ArtistDetailPageModule' },
{ path: 'artist', loadChildren: './artist/artist.module#ArtistPageModule' },
];
Маршруты вкладок:
const routes: Routes = [
{
path: 'tabs',
component: TabsPage,
children: [
{
path: '',
redirectTo: '/tabs/(home:home)',
pathMatch: 'full',
},
{
path: 'home',
outlet: 'home',
component: HomePage
},
{
path: 'timetable',
outlet: 'timetable',
component: TimetablePage
},
{
path: 'artist',
outlet: 'artist',
component: ArtistPage
}
]
},
{
path: '',
redirectTo: '/tabs/(home:home)',
pathMatch: 'full'
}
];
Вкладки
<ion-tab label="Dashboard" icon="home" href="/tabs/(home:home)">
<ion-router-outlet name="home"></ion-router-outlet>
</ion-tab>
<ion-tab label="Zeitplan" icon="time" href="/tabs/(timetable:timetable)">
<ion-router-outlet name="timetable"></ion-router-outlet>
</ion-tab>
[...]
Страница вкладок, которая перемещается на подстраницу вкладки с помощью routerLink
<div class="venue-box animated fadeIn fast delay-500ms" *ngFor="let artist of data" routerLink="/artistDetail/{{artist.id}}" [ngStyle]="{'background-image': 'url(' + artist?.imagePath + ')'}">
<div class="box">
<h1>{{artist?.name}}</h1>
<p>{{artist?.subtitle}}</p>
</div>
</div>
Заголовок на подстранице:
<ion-header>
<ion-toolbar color="primary">
<ion-buttons slot="start">
<ion-back-button></ion-back-button>
</ion-buttons>
<ion-title>{{artist}}</ion-title>
</ion-toolbar>
</ion-header>