Getting the component name or using various methods give the letter t in return.
This has been seen in the Tabs template.
Note that this only happens on the device. It works fine in the browser.
console.log(this.navCtrl.getActive().component.name);
console.log(nav.getActive().component.name);
console.log(this.tabRef.viewCtrl);
Name of the component or view is expected
Steps to reproduce:
Which Ionic Version? 1.x or 2.x
Ionic 2 RC0
Hello, thanks for using Ionic! This is actually expected due to our AoT compiling that happens when doing a prod build. Ionic does a prod build when doing ionic run android/ios, ionic emulate android/ios or ionic build android/ios. All of the methods will still work the same as the name, which is t in this case, still refers to the same component.
Hi @jgw96 ,
What I should do to get the name property, instead of t, or e, or r property?
What I should do to get the name property, instead of t, or e, or r property?
+1
We can get component-name with "this.nav.getActive().id" in AoT.
not use "name".
its working "this.nav.getActive().id" in AoT.
thanks
This doesn't seem to work as of currently (ionic CLI 3.18.0, ionic-angular 3.7.1). "this.nav.getActive().id" returns a shortened string like "tn-4", not the original component name. I'm using this method in production to send telemetry about view navigation, so the original component name is what I'm looking for. Is there any other way to obtain it?
+1
We are also seeing this issue as it is actually reporting the name as blank when running ionic cordova run browser --prod. With the name being reported as mentioned before without the --prod
+1
+1
Could be very useful to have component name also in "ionic build --prod"!
+1 plz....
If you need name just to compare with specific page / component, you can copare active component with that component directly:
let activeView = this.navCtrl.getActive(); if (activeView.component == ConversationPage) { }
as ruben0909 mentioned here. It helped me a lot.
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.