Cannot retrieve name of a modal component


#1

I want to add some logging to all my pages. Mainly I want to log the ionViewDidEnter event. Since I need this functionality on every page, I do not want to add the component’s name there hard-coded. Instead I want to use a more generic approach.

The following is working well for pages:

public ionViewDidEnter(): void {
  let viewName = this.navController.first().name;
  ...
}

However, when I add the same code to a modal’s component, viewName has always the value ModalCmp.

Is there a way to retrieve the name of the modal’s component generically?


#2

I tried App in my app.component.ts file may be this help you…!! (In RC 4)

import { App } from 'ioni-angular';

if(this.app.getActiveNav().getActive().isOverlay == true){
   let currentModal = this.app.getActiveNav().getActive().data;
   console.log(currentModal.component.name)
}