Exploring two main pages, each with tabs displaying two negative behaviors

I developed an app with an ion-footer at the bottom of each root page :

<ion-footer>
  <ipa-footer-buttons></ipa-footer-buttons>
</ion-footer>

The <ipa-footer-button> component is structured as follows:

html:

<ion-toolbar>
  <ion-buttons class="footer-buttons">
    <!--Main-->
    <button ion-button block color="icons-color" (click)="footerClick('MainTabsPage')">
      <div [ngClass]="{'active': currentPage == 'MainTabsPage', 'inactive': currentPage != 'MainTabsPage'}">
        <ion-icon name="md-home"></ion-icon>
        <label class="title-icon-footer">Main Page</label>
      </div>
    </button>


    <button ion-button block color="icons-color" (click)="footerClick('MyAccountTabsPage')">
      <div [ngClass]="{'active': currentPage == 'MyAccountTabsPage', 'inactive': currentPage != 'MyAccountTabsPage'}">
        <ion-icon name="md-person"></ion-icon>
        <label class="title-icon-footer">My Account</label>
      </div>
    </button>
  </ion-buttons>
</ion-toolbar>

component.ts:

constructor(private _app: App) {
    this._app.getRootNav().viewDidEnter.subscribe((next: ViewController) => {
      this.currentPage = next.name;
    })
  }
footerClick(page) {
    switch (page) {
      case 'MainTabsPage'://main page
        this._app.getRootNav().setRoot('main-tabs', {tabIndex: 0}, {updateUrl: true});
        break;
      case 'MyAccountTabsPage':
        this._app.getRootNav().setRoot('my-account-tabs', {tabIndex: 0}, {updateUrl: true});
        break;
    }
  }

When navigating from Main page to My account page, I encountered two issues. Firstly, the tabs from the Main page still appeared for 2 seconds on the My Account page. Secondly, the footer buttons lost their color when navigating between them. Normally, the active button should change color to indicate the current page, but in this case, both buttons remained the same color.

Versions used: ionic (Ionic CLI) : 4.0.2 Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.2.0

If anyone has insights into what might be causing these issues, please let me know!

Answer â„–1

Have you explored the possibilities of utilizing the Ionic ion-tabs component (found in the documentation here)?

This component handles the active and inactive display automatically. I encountered some transition issues when switching between pages, which I managed to resolve by removing the animation effect. In your scenario, the code snippet would look like this:

this._app.getRootNav().setRoot('my-account-tabs', {tabIndex: 0}, {updateUrl: true, animate: false});

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

npm is unable to install the package called 'node-sass'

So, I'm running a project with npm start and suddenly encountering the same error in multiple components: Module build failed: Error: Cannot find module 'node-sass' Frustrated, I decide to run 'npm install node-sass', only to be ...

Angular - combining lowercase letters in an attribute

Hello, I'm new to using Angular and currently working on creating an attribute within a div tag. I have successfully achieved this task. However, I am in need of changing my input to lowercase during the concatenation. <!--"Fade" Slider--> < ...

Angular: accessing public properties

I have a component called "user.service.ts" that I want to share. import { Injectable } from '@angular/core'; import { Http, Headers, RequestOptions, Response } from '@angular/http'; import { AppConfig } from '../app.config&apos ...

Exploring Transformation in Angular

I am looking to enhance my understanding of how ChangeDetection works, and I have a query in this regard. When using changeDetection: ChangeDetectionStrategy.OnPush, do I also need to check if currentValue exists in the ngOnChanges lifecycle hook, or is i ...

Tips for maintaining an active Angular PWA while your device is in doze mode

We are currently in the process of creating an angular progressive web application that receives updates from a LightStreamer Server and displays notifications to the user. Since PWAs serve as alternatives to native apps, we are aiming for our app to rem ...

Using a decorator with an abstract method

Discussing a specific class: export abstract class CanDeactivateComponent { abstract canLeavePage(): boolean; abstract onPageLeave(): void; @someDecorator abstract canDeactivateBeforeUnload(): boolean; } An error occurred stating that A decorat ...

Eliminating an index from a JSON array using Typescript

I'm working with a JSON array/model that is structured as follows: var jsonArray = [0] [1] ... [x] [anotherArray][0] [1] ... [e] My goal is to extract only the arrays from [0] to [x] and save them into their ...

Strange behavior in Angular's http response

When I make a call to my API and receive a JSON response, the code snippet below illustrates how I handle it: getAllLearn() { this.learnService.getAllLearn().subscribe(res =>{ // The console log shows that res.featured only has one index: ( ...

Exploring PrimeNG's method for expanding and collapsing groups

I'm attempting to incorporate two buttons that can be used to either expand or collapse all the groups in my code utilizing primeNG. Below is the functioning code: PLUNKER <p-dataTable [value]="data" sortField="room" rowGroupMode="subheader" grou ...

How to store property transformation in Redux/ngrx

I have the following setup someReducer.ts export interface State { someProp: MyModel; } // some action listeners .. // // export const getProp = (state: State) => state.someProp; selector.ts export const getProperty = createSelector(getState, f ...

Dividing component files using TypeScript

Our team has embarked on a new project using Vue 3 for the front end. We have opted to incorporate TypeScript and are interested in implementing a file-separation approach. While researching, we came across this article in the documentation which provides ...

Interfaces in Typescript

In my Angular 2 project, I am working on creating an interface for a complex object. Here is the code snippet of the object: // Defining the render state object this.aRenderState = { model: "", colour: false, showWireframe: false, showGrid: true, ...

Creating a Versatile Data Retrieval Hook in TypeScript for APIs with Diverse Response Formats

Currently, I am undertaking a movie discovery project that involves fetching data from two APIs: Tmdb movie site. These APIs have different response structures—one for movies and one for genres. In order to streamline my code and avoid repeating the same ...

Storing a portion of JSON data within a function called in the HTML document

I've been working with Angular and need to save a portion of JSON data in a variable within a function that is called in an HTML file: <select id="postazione" onchange="postazioneSelezionata()"> <option value="" selected disabled >Cho ...

What is the best way to overload a function based on the shape of the argument object in

If I am looking to verify the length of a string in two different ways (either fixed or within a specific range), I can do so using the following examples: /* Fixed check */ check('abc', {length: 1}); // false check('abc', {length: 3}) ...

Middleware transformation pipeline implemented using Typescript types

In my quest to create a function that empowers middlewares (specifically Express ones) to enhance the Request object by adding properties to it, I aim for subsequent middlewares in the chain to utilize these additions while preserving data types. An examp ...

Angular confirmation page following successful HTTP POST request to Web API

First question here... I have been given the task of improving an Angular application, even though I am starting with zero experience in Angular. While I do have some background in JavaScript, I mostly work with Java (JSP's and yes, JavaScript). Despi ...

Eliminate any repeated elements in the array by utilizing TypeScript

Hey, I'm trying to figure out how to remove duplicate entries from an array where the UserId values are the same, and keep only one of each unique entry. Can anyone help me with this? For example: a=[ {userId:1,name:''}, {userId:2,name:&apo ...

Having trouble sending an image to the API endpoint using Angular 6 reactive form

Currently utilizing Angular 6 along with Reactive Form The task at hand involves uploading a user avatar image, which led to the creation of a change-avatar component containing the code provided below. import {Component, OnInit, ViewChild} from '@a ...

Several of your tests performed a complete page refresh

While conducting unit tests in Angular, I encountered the following error: ALERT: 'Add Success!' Chrome 58.0.3029 (Windows 10 0.0.0) ERROR Some of your tests triggered a full page reload! Chrome 58.0.3029 (Windows 10 0.0.0): Executed 0 of 1 ER ...