How to conceal tabs on secondary pages within an Ionic 2 app

Seeking a solution to hide tabs on subpages within an app, I have tried utilizing the following code:

<ion-tab [root]="MyPage" tabsHideOnSubPages="true" ...></ion-tab>

While this code works when running 'ionic serve,' it fails to hide the tabs on my devices, rendering them unusable in subpages.

Does anyone have any ideas on how to successfully hide the tabs on my devices?

[update] Removing a Google map from a child page seems to resolve the issue.

Child page .html :

<ion-header>
  <c-header></c-header>
</ion-header>

<ion-content>
  <div id="map"></div>
</ion-content>

Child page .css :

#map {
  height: 50%;
}

Child page .ts :

import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';
import { GoogleMap, GoogleMapsEvent, GoogleMapsLatLng } from 'ionic-native';

/*
  Generated class for the DetailsMedicalEvent page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.
*/
@Component({
  selector: 'page-details-medical-event',
  templateUrl: 'details-medical-event.html'
})
export class DetailsMedicalEventPage {

  map: GoogleMap;

  constructor(public navCtrl: NavController, public platform: Platform) {
    platform.ready().then(() => {
      this.loadMap();
    });
  }

  loadMap(){

    let location = new GoogleMapsLatLng(-34.9290,138.6010);

    this.map = new GoogleMap('map', {
      'backgroundColor': 'white',
      'controls': {
        'compass': true,
        'myLocationButton': true,
        'indoorPicker': true,
        'zoom': true
      },
      'gestures': {
        'scroll': true,
        'tilt': true,
        'rotate': true,
        'zoom': true
      },
      'camera': {
        'latLng': location,
        'tilt': 30,
        'zoom': 15,
        'bearing': 50
      }
    });

    this.map.on(GoogleMapsEvent.MAP_READY).subscribe(() => {
      console.log('Map is ready!');
    });
  }
}

Having a map is essential to my requirements. Has anyone else encountered this issue before?

Answer №1

To easily hide tabs on subpages, you can set the tabsHideOnSubPages configuration property within the app.module.ts file as shown below:

... 
imports: [
    IonicModule.forRoot(MyApp, {
        // Tabs config
        tabsHideOnSubPages: true,
        ...
    })
]
...

As per the Ionic documentation:

tabsHideOnSubPages: boolean

This property determines whether to display tabs on child pages. Setting it to true will hide tabs on child pages.

Answer №2

Adding "tabsHideOnSubPages: true" to app.module.ts solved the issue for my Ionic 2 project.

Answer №3

If you want the option to easily control when the tabs are visible or hidden, a simple CSS class can do the trick:

.tab-section.hidden ion-tab-bar {
    display: none;
}

In your tabs controller file, create a boolean variable to determine the visibility of the tabs:

public showTabs: boolean = true;

Add ngClass to the ion-tabs element in your HTML template to toggle the 'hidden' class based on the value of the showTabs variable:

<ion-tabs [ngClass]="{'hidden': !showTabs}">

You have the flexibility to change the showTabs variable in various functions like when navigating to different pages or within Ionic's lifecycle hooks such as ionViewWillEnter().

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I'm looking to transform this array into the format described below, and also include another nested subarray within it using TypeScript

[{ "header": "API", "value": "hello" }, { "header":"API", "value":"yellow" }, { "header":"Other", "value":"yallow"}, { "header":"other", "value":"othertt" } ] I have a list of objects with he ...

Error with tsc rootDir due to Docker's installation of yarn in root directory

I am encountering a problem with my node project which serves a simple "hello world" server. Everything runs smoothly when I run it locally, but when I try to run it inside Docker, a /opt/yarn-v1.21.1 folder is created which leads to a rootDir error: erro ...

Learn how to host a singular instance of an Angular application for every unique route, similar to the setup utilized in meet.jit.si

Is there a way to create an Angular app that loads a new instance of itself on every route/url? For example, visiting http://happy-app.com/happy would show the app in one state, and going to http://happy-app.com/happier would load the same app in a differe ...

Incorporating Angular supplementary elements into the index.html file

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>UdemyApp</title> <app-settings></app-settings> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1. ...

What is the best way to strip strings and special characters from a text, displaying only the numerical values without any commas, by

Using React Native TypeScript, I am looking to extract only the numbers from a string group without any commas. Is there a way to achieve this using regex match or replace? taskname = TASK_XC0.0.0.0.89t_abc_test let task = taskname.match( /[0-9]+/g, &apo ...

Simulating NgRx store using a selector in Angular version 10

I am a novice when it comes to creating test cases, however, I have been tasked with writing tests for an Angular 10 app that utilizes ngrx to manage user information. Below is the ngOnInit function: this.store.pipe(select(userInfo)).subscribe((data) => ...

Ionic Framework: Eliminating the tiny 1px vertical scroll glitch for single-line content

Is anyone else experiencing this issue? I noticed that my page content is not filling up the entire space, even though it's just one line of text. There seems to be a 1px vertical scroll present, and the same problem occurs with the content in the sid ...

Encountering an Error on WSL while attempting to convert a ReactJS project to an Android app using Ionic Capacitor

Currently, I am developing a straightforward Web-App and I opted to utilize ReactJS as my Framework. To kick things off, I set up a basic demo Project with create-react-app. My operating system is Windows 10 with the Linux Subsystem. Recently, I recei ...

What could be causing Angular to display errors originating from my node_modules directory?

After initiating ng serve, the server starts successfully but then displays a series of errors such as: chunk {main} main.js, main.js.map (main) 2.02 kB [initial] [rendered] chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 689 bytes [initial] [ ...

The absence of a semicolon following the interface declaration is the issue

I am facing a slight issue with ESLint and Typescript, particularly regarding semicolons after declaring interfaces. Additionally, I utilize VSCode as my editor with automatic formatting upon saving. Below is the configuration in my .eslintrc.json file: ...

What is the best way to empty session storage in Angular when the browser tab is closed?

Every time I access my browsing history, it automatically logs me in. However, if I try to enter the URL in a new tab, I am redirected to the login page. I have already attempted to clear the session by using browser tab close events. // 1 @HostListener(&a ...

Converting a string to Time format using JavaScript

I am working with a time format of 2h 34m 22s which I need to parse as 02:34:22. Currently, I am achieving this using the following code: const splitterArray = '2h 34m 22s'.split(' '); let h = '00', m = '00', s = &a ...

Using TypeScript, create a functional component for a private route in React

When I encounter the error message below, can you please explain where this issue is originating from? No overload matches this call. Overload 1 of 2, '(props: Readonly<RouteProps>): Route<RouteProps>', gave the following error. ...

Inheriting an Angular 5 class with injected dependencies

I recently defined a new class @Injectable FooService { constructor(private _bar:BarService){ } } Then I decided to extend it in the following way @Injectable ExtFooService extends FooService { constructor(private _bar:BarService){ ...

How do I assign a default value to an optional parameter in a derived class in Typescript?

One of my classes is called ClientBase: export class ClientBase { constructor(private uri: string, private httpClient: HttpClient) { } // Contains Various Methods } I have multiple subclasses that are derived from the ClientBase For instance: @I ...

Tips for determining the datatype of a callback parameter based on the specified event name

Let's say we have the following code snippet: type eventType = "ready" | "buzz"; type eventTypeReadyInput = {appIsReady: string}; interface mysdk { on:(event: eventType, cb: (input: eventTypeCallbackInput) => void) => void } mysdk.on("ready", ...

Revitalizing ngFor in Angular 9: Refreshing object properties for re-rendering

I am currently working with an array of objects named Guests: [ {id: 1, first_name: "Tom", last_name: "", logo: 2}, {id: 2, first_name: "John", last_name: "", logo: 3}, {id: 3, first_name: "Jim", l ...

Aligning Description Item components horizontally in antdLearn how to easily horizontally align Description

Currently, I am utilizing the `antd` Description components. In this scenario, when there is no `title` for the items, the value should be aligned to the left. You can see an example of this alignment in the image below: https://i.sstatic.net/Ah70f.png I ...

Can markdown generated HTML be bound to an Angular 4 component?

I'm currently using Angular 4 to develop an app similar to a wiki, allowing users to create their own pages and link them using a markdown text editor controlled by a component/directive. That's the goal, at least. For example: The custom markd ...

Transform the data types in interfaces to promises

In Typescript, there is a Partial<Object> type that allows all fields of an object to be optional. Can we create a generic type Promisify<Person> in the same way, transforming the Person type from: interface Person { getName(): string; ge ...