Hi,
I have two tabs and following nav structure:
- Tab1: News (List of articles)
1.1. Single article view - Tab2: About page (simple page with button)
When Tab2 is active, I would like to tap on ‘Go to article’ button and open article view (it works) but I would like to highlight Tab1 also. Moreover when single article view is opened I would like to back to list of articles (not to about page).
How can I do that?
Thanks in advance
tabs.ts
import { Component } from '@angular/core';
import { NewsView } from '../news/news';
import { AboutView } from '../about/about';
@Component({
templateUrl: 'tabs.html'
})
export class TabsPage {
tab1: any = NewsView;
tab2: any = AboutView;
constructor() {}
}
news.ts
import { Component, ViewChild } from '@angular/core';
import { NavController, Nav } from 'ionic-angular';
import { ArticleView } from '../article/article';
@Component({
selector: 'news',
templateUrl: 'news.html'
})
export class ArticlesView {
constructor(public navCtrl: NavController) {
}
goTo() {
this.navCtrl.push(ArticleView);
}
news.html
<ion-header>
<ion-navbar>
<ion-title>News</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<button (click)="goTo()" ion-button full>Go to single view</button>
</ion-content>
article.ts
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
@Component({
selector: 'article',
templateUrl: 'article.html'
})
export class ArticleView {
constructor(public navCtrl: NavController) {}
}
about.ts
import { Component, ViewChild } from '@angular/core';
import { App, NavController, Tabs } from 'ionic-angular';
import { ArticleView } from '../article/article';
@Component({
selector: 'about',
templateUrl: 'about.html'
})
export class AboutView {
constructor(public navCtrl: NavController) {}
openArticle(){
this.navCtrl.push(ArticleView);
}
}
about.html
<ion-header>
<ion-navbar>
<ion-title>About</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<button (click)="openArticle()" ion-button full>Go to article</button>
</ion-content>