Ionic3 footer using ion-tabs

Is there a way to create a common footer for all pages with 5 buttons, where the first button is selected by default? The page opened by this first button should have three tabs. I have already created the tabs but am unsure how to add the footer without repeating it on every single page. Any suggestions?

tabsHideOnSubPages: true
<ion-tabs [selectedIndex]="mySelectedIndex"
          name="mainTabs"
          tabsPlacement="top"
          tabsLayout="icon-hide"
          tabsHighlight="true"
          [ngClass]="showTabs? 'appear-tabs':'disappear-tabs'">
  <ion-tab [root]="exploreRoot" tabTitle="A"></ion-tab>
  <ion-tab [root]="spotlightRoot" tabTitle="B"></ion-tab>
  <ion-tab [root]="webinarsRoot" tabTitle="C"></ion-tab>
</ion-tabs>

footer:

<ion-footer>
  <ion-toolbar>
    <ion-buttons>
      <!--Main-->
      <button ion-button block color="icons-color">
        <div>
          <ion-icon name="md-home"></ion-icon>
          <label class="title-icon-footer">AAA</label>
        </div>
      </button>
      <!--my Programs-->
      <button ion-button block color="icons-color">
        <div>
          <ion-icon name="ios-play"></ion-icon>
          <label class="title-icon-footer">BBB</label>
        </div>
      </button>
      <!--my webinars-->
      <button ion-button block color="icons-color">
        <div>
          <ion-icon name="md-desktop"></ion-icon>
          <label class="title-icon-footer">CCC</label>
        </div>
      </button>
      <!--my notification-->
      <button ion-button block color="icons-color">
        <div>
          <ion-icon name="md-notifications"></ion-icon>
          <label class="title-icon-footer">CCC</label>
        </div>
      </button>
      <!--my account-->
      <button ion-button block color="icons-color">
        <div>
          <ion-icon name="md-person"></ion-icon>
          <label class="title-icon-footer">DDD</label>
        </div>
      </button>
    </ion-buttons>
  </ion-toolbar>
</ion-footer>

Answer №1

I decided to take a different approach and opted not to use tabs. Instead, I created a footer component that was included on every page. By passing the navController from the page to the footer, I enabled the footer to navigate to different pages.

In each page's .html file:


<ion-footer>
    <my-footer [navController]="navController"></my-footer>
</ion-footer>

Footer component .html


<ion-grid no-padding>
    <ion-row align-items-center>
        <ion-col col-6 text-center>
            <button ion-button icon-only (click)="gotoPage('HomePage')">
                <ion-icon name="md-apps"></ion-icon>
                <span>Home</span>
            </button>
        </ion-col>
        <ion-col text-center>
            <button ion-button icon-only (click)="gotoPage('ContactPage')">
                <ion-icon name="md-list-box"></ion-icon>
                <span>Contact</span>
            </button>
        </ion-col>
    </ion-row>
</ion-grid>

Footer component .ts import { Component, Input } from '@angular/core'; import { NavController } from 'ionic-angular';

@Component({
    selector: 'mwc-footer',
    templateUrl: 'mwc-footer.html'
})
export class MwcFooterComponent {

    @Input('navController') navController;

    constructor() { }

    public gotoPage(page: string): void {
        this.navController.setRoot(page);
    }
}

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

Determination of an arc trajectory using JavaScript

I have been trying to figure out how to replicate this effect. The Red arrowhead remains stationary while the background features a curved path. Currently, I am adjusting the background position to give the illusion of the arrowhead moving along the curved ...

Writing in Node.js involves setting up a local DynamoDB for local development rather than running it in an actual Lambda

This straightforward aws.js script is used to execute dynamoDB operations locally. "use strict"; const AWS = require("aws-sdk"); AWS.config.dynamodb = { region: "eu-west-2", endpoint: "http://localhost:8000& ...

"Utilizing jQuery's AJAX POST method with PHP is successful, while using XMLHttpRequest is not yielding

Currently in the process of revamping my existing code to transition from jQuery's AJAX function to using XMLHttpRequest in vanilla JS. My understanding is that the following code snippets should be equivalent. However, while the jQuery version functi ...

Can you explain the mechanics behind Google Voice Search? And is there an available API for it?

Is this the right place to ask how the voice-activated search feature on Google's homepage functions? I'm curious about whether it utilizes Flash, a plugin integrated into Google Chrome, or some other method to access the microphone. The idea of ...

What is the best way to get the latest props in the midst of an async function?

There's a fascinating open-source project called react-share, where the ShareButton component offers a prop known as beforeOnClick for customization. I've utilized this beforeOnClick to upload images to our CDN before sharing, ensuring that only ...

Display or conceal specific fields depending on the selection from a dropdown menu

I'm currently experimenting with using JavaScript and/or jQuery to dynamically hide specific HTML elements based on the selection in a drop down menu. Here is what my page setup looks like: [Drop down menu] [text field 1] [text field 2] [text field ...

How can I activate a disabled option number 2 after selecting option number 1?

I have encountered an issue with my JavaScript code. The second "select" element is supposed to be disabled by default, but I want it to become enabled when an option is selected from the first "select". However, this functionality is not working as expect ...

The data type 'string' cannot be assigned to type 'E164Number' in the react-phone-number-input component

I'm currently utilizing a library called react-phone-number-input. Within my project, I have two important files: index.tsx and useLogicRegister.ts. While working on my code, I encountered an error stating Type 'string' is not assignable to ...

Issues with displaying ngAnimate animations

For the past 10 hours, I've been attempting to get my animations to function properly. It seems that they only work when I include the animate.css stylesheet and use the "animated classname". However, when I try to create custom entrance and exit anim ...

What is the method for pulling information from MySQL and presenting it on a website using Node.js?

Currently, my goal is to retrieve data from MySQL and showcase it on my HTML page. The code snippet in server.js looks like this: const path = require('path'); const express = require('express'); const bodyParser = require("body-pa ...

In Angular, the exclusion of a name attribute in a textarea element does not automatically generate an instance

I came across this jade template for creating a modal dialog in Angular Material. Unfortunately, I couldn't convert it to HTML because the jade site was not working. md-dialog(aria-label='Reject', ng-cloak='') form(name="rejecti ...

Exploring the differences between arrays and objects provided by users

I am working on a functionality that involves comparing user input with predefined usernames and passwords. Here is what I have so far: var sys = { users: [ {user: 'user1', pass: 'qwerty'}, {user: 'Ragnar&apos ...

Is your Node.js asynchronous parallel function not performing as expected?

I have a series of promises that I need to execute sequentially, but it's getting messy with all the promise returns. To simplify this process, I decided to use the async library and tried out the parallel method. However, instead of running one after ...

Having trouble organizing the date strings in the material table column

In my Angular application, I have a material table with multiple columns that I am sorting using matSort. While I can successfully sort the last two columns in ascending or descending order, I am facing an issue with the first column which contains date va ...

Retrieve the Javascript variable and assign it to a PHP variable

When attempting to assign a JavaScript variable to a PHP variable and output the value in an alert, I am encountering an error. The output is shown as "; alert(simple); var p1sds = "My Custom String"; <?php $dsfd = "<script>document.writeln(p ...

Developing a web-based form using an ES6 module

I'm currently experimenting with an ES6 webpage to design a simple webpage featuring just an email form. The form includes fields for Name, Email, and Subject, a message text box, and a send button that is linked to a PHP script to deliver the email ( ...

Issue with Vue class binding failing to update when state is modified

I'm attempting to utilize Vue class binding depending on the index within the v-for loop. While I can see that the state in Vue dev tools is changing correctly, the class name itself isn't being updated. <div class="group" v-for= ...

Struggling with the Nivo slider not loading properly?

Check out my personal website. I'm having an issue with my Nivo slider not displaying properly - it just keeps loading. Any ideas on why this is happening and how I can fix it? Below is the CSS I am using: #slider { position:relative; width: ...

Tips on utilizing Selenium with Java to locate and interact with elements on an Angular web application

I'm facing challenges with automating an Angular web app. Despite trying simple code, it still isn't working. Here's an example of my code: @BeforeClass public void setUp() { ChromeOptions options = new ChromeOptions(); ...

How can I dynamically pass a background:url using JavaScript to CSS?

I have a CSS code snippet below that I would like to dynamically change the "background:url" part using Javascript. div{ background: url('pinkFlower.jpg') no-repeat fixed; -webkit-background-size: cover; -moz-background-size: cover; ...