Popup appears on incorrect page

As part of my app development project, I implemented a popover feature that opens when clicking on a label. Initially, this functioned smoothly within a tab navigation setup. However, after transitioning from tab modules to the app-routing module to display tabs on every page, I encountered an issue. When attempting to open the popover labeled "rateus" by clicking on the label "bewertung" on the 5th tab ("more"), it fails to appear. Strangely, the popover opens on the 1st tab ("home") instead, rendering it inaccessible for interaction.

more.page.ts

import { Component, OnInit } from '@angular/core';
import { ModalController, NavController, PopoverController } from '@ionic/angular'
import { RateusPage } from 'src/app/popover/rateus/rateus.page';

@Component({
  selector: 'app-more',
  templateUrl: './more.page.html',
  styleUrls: ['./more.page.scss'],
})
export class MorePage implements OnInit {

  constructor(
    private popoverController: PopoverController,
    private modalController: ModalController
  ) { }

  ngOnInit() {
  }

  async presentPopover() {
    console.log('I got clicked')
    const popover = await this.popoverController.create({
      component: RateusPage,
    });
    popover.present();
  }
}

rateus.page.html

<ion-item>
  <ion-label>
    Bewertung
  </ion-label>
</ion-item>
<ion-content padding>
  <ion-button expand="full" (click)=rateusDismiss()>Close</ion-button>
</ion-content>

rateus.page.ts

import { Component, OnInit } from '@angular/core';
import { PopoverController } from '@ionic/angular';

@Component({
  selector: 'app-rateus',
  templateUrl: './rateus.page.html',
  styleUrls: ['./rateus.page.scss'],
})
export class RateusPage implements OnInit {

  constructor(private popoverController: PopoverController) { }

  ngOnInit() {
  }

  rateusDismiss(){
    console.log("dismiss")
    this.popoverController.dismiss();
  }
}

Answer №1

After some troubleshooting, I managed to identify the issue in my app.component.html file. Initially, it was structured like this:

<ion-app>
  <ion-router-outlet></ion-router-outlet>
</ion-app>

<ion-tabs>
  <ion-tab-bar slot="bottom">
    
    <ion-tab-button tab="home">
      <ion-icon name="home"></ion-icon>
      <ion-label>Home</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="shop">
      <ion-icon name="cart"></ion-icon>
      <ion-label>Shop</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="inbox" (click)="loginrequired()">
      <ion-icon name="mail"></ion-icon>
      <ion-label>Postfach</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="profile" (click)="loginrequired()">
      <ion-icon name="person"></ion-icon>
      <ion-label>Profile</ion-label>
    </ion-tab-button>

    <ion-tab-button tab="more">
      <ion-icon name="ellipsis-horizontal"></ion-icon>
      <ion-label>Mehr</ion-label>
    </ion-tab-button>
  </ion-tab-bar>
</ion-tabs>

However, it needed to be restructured to this format:

<ion-app>

  <ion-router-outlet></ion-router-outlet>

  <ion-tabs>

    <ion-tab-bar slot="bottom">

      

      <ion-tab-button tab="home">

        <ion-icon name="home"></ion-icon>

        <ion-label>Home</ion-label>

      </ion-tab-button>

      <ion-tab-button tab="shop">

        <ion-icon name="cart"></ion-icon>

        <ion-label>Shop</ion-label>

      </ion-tab-button>

      <ion-tab-button tab="inbox" (click)="loginrequired()">

        <ion-icon name="mail"></ion-icon>

        <ion-label>Postfach</ion-label>

      </ion-tab-button>

      <ion-tab-button tab="profile" (click)="loginrequired()">

        <ion-icon name="person"></ion-icon>

        <ion-label>Profile</ion-label>

      </ion-tab-button>

      <ion-tab-button tab="more">

        <ion-icon name="ellipsis-horizontal"></ion-icon>

        <ion-label>Mehr</ion-label>

      </ion-tab-button>

    </ion-tab-bar>

  </ion-tabs>

</ion-app>

Answer №2

To ensure Ionic knows where to position the popover in the DOM, make sure to include the browser event along with the popover controller when adding the click event.

async showPopover(event: Event) {
    console.log('Popover clicked')
    const popover = await this.popoverController.create({
      component: ReviewPage,
      event: event
    });
    popover.present();
  }

Remember to call the function in your HTML code like so:

<ion-button expand="full" (click)=showPopover($event)>Open popover</ion-button>

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

Encountering an issue while trying to utilize Vuex in Vue with TypeScript

I recently utilized npm to install both vue (2.4.2) and vuex (2.3.1). However, when attempting to compile the following code snippet, I encountered the following error: https://i.stack.imgur.com/0ZKgE.png Store.ts import Vue from 'vue'; import ...

Mapping JSON schema to typed JavaScript objects

Are there any tools available to generate JavaScript typed objects (JS functions) from a JSON schema? Essentially, looking for the JS equivalent of this http://code.google.com/p/jsonschema2pojo/. Thank you. EDIT: Starting with: { "description": "An ...

How to incorporate both image and text links within an HTML div container using JavaScript

I am trying to create a clickable image and text within a div named "films" that both link to the same webpage. However, I am experiencing an issue where only the text link works and the image link is disabled. If I remove the text link, then the image l ...

I'm having trouble extracting data into my HTML file using the append function in Jquery. What could be causing this issue?

Hey there, I'm having some trouble extracting data from a URL to my HTML file using jQuery. Can anyone help out? I'm still new to this. Here's the code <html> <head> <title> My Program </title> <script src="ht ...

Vuex is exclusively eliminating the initial element

Currently, I have set up the code to remove the activeNote from the array called notes by using the DELETE_NOTE mutation. However, it seems that it only removes the first element of the array. The content of mutations.js is as follows: export const mutat ...

Is your Javascript navigation functioning properly on some submenus while encountering issues on others?

If you visit , you'll notice that it's a visually appealing site. The navigation submenus seem to be functioning properly, HOWEVER upon inspecting the element, you'll notice that under the PRICING tab, there are submenus that have the same c ...

What is a more efficient method for switching between edit mode and view mode in ng-grid?

Up until now, I've only managed to switch the edit mode in ng-grid by using separate templates and showing the correct template based on user input. For example: Plunker (resize a column and then switch to another mode) This poses a problem because ...

Implementing centralized authentication through an IdentityServer application with the utilization of the resource owner password flow

I am currently developing two Angular 2 applications that will have a .NET Core 1.1 REST backend and be hosted on Azure App Service. My goal is to enable them to share authentication information in order to provide a seamless Single Sign-On experience. Add ...

Exploring the World of 3D Rotation with Three.js

I currently have 2 mesh objects - the Anchor and the Rod. The Anchor rotates around the z-axis, as shown in the image. The Rod is designed to only move backward and forwards. You can view the image here: . However, I am struggling to determine the matrix ...

Guide on implementing the recently established attribute ID using jQuery

In my code snippet, I am assigning a new id to a button. Here is the code: $("#update").click(function(){ $("#update").attr('id', 'cancel'); }); After changing the id, I want to make it functional again in jQuery by reverting it b ...

Could the autofill feature in Chrome be turned off specifically for Angular form fields?

Even after attempting to prevent autofill with autocomplete=false and autocomplete=off, the Chrome autofill data persists. Is there a method to disable autofill in Angular forms specifically? Would greatly appreciate any recommendations. Thank you. ...

Creating a dynamic dropdown list with PHP and AJAX using JQuery

I was attempting to create a dynamic dependent select list using AJAX, but I am facing issues with getting the second list to populate. Below is the code I have been working with. The gethint.php file seems to be functioning properly. I'm not sure whe ...

Guide to customizing the default scrollbar colors in Nextjs

When browsing websites like tailwindcss.com or https://developer.mozilla.org/ in Chrome and Firefox, you may have noticed that they utilize the default scrollbar style but allow users to change its colors through a dark/light mode button. The appearance of ...

Troubleshoot: Issue with Multilevel Dropdown Menu Functionality

Check out the menu at this link: The issue lies with the dropdown functionality, which is a result of WordPress's auto-generated code. Css: .menu-tophorizontalmenu-container { margin: 18px auto 21px; overflow: hidden; width: 1005px; ...

Stop accidental clicking on objects in React-Fiber which are using Three.js

Check out this interactive cube made up of planes! An issue I've encountered is that clicking on a plane passes through to the ones behind it, rather than only registering a click on the plane directly under my mouse. Any suggestions for fixing this ...

Discover the process of utilizing doc.getElementbyClassName to determine if any of its elements are blank

On my HTML invoice table, I sometimes have empty elements that cause the row to misalign. To fix this, I want to add whitespace if an element is empty. Here is the structure of the table: <div class="invoiceTable"> <div class="titles2" style=" ...

AngularJS - Array binding issue not updating in directive

I am currently developing a directive that has the ability to display a series of controls. Each individual control is implemented as a directive named fsFilter. In the controller managing the parent element, I establish a binding between the filters arra ...

Step-by-step guide: Assigning a color to a card element in MaterializeCSS

I am currently working on a project using Vue.js where I want to display colored cards from MaterializeCSS. The colors are stored as hex codes in a separate database and are part of items looped through with the v-for loop, like this: <div ...

Unable to invoke the Socket.on() function in NodeJS

I have set up a PHP web app and I am trying to integrate nodeJS into it. I followed a tutorial on nodeJS and got it working fine on localhost:3000. But now, I want to run it on a specific URL like localhost/final/chat/chat_index.html. To achieve this, here ...

Guide on creating a conditional column in a kendo UI grid with the use of AngularJS

Is there a way to dynamically add a column to the Kendo UI grid based on JSON data? Consider the following JSON input: [{ "ProductID": 1, "ProductName": "Chai", "Supplier": { "SupplierID": 1, "SupplierName": "Exotic Liquid ...