getComponent alternative


#1

Hello since getComponent is no longer available i have the next scenario.

Inside app.ts and app.html i have a menu component and a nav component.
Inside the nav component i am adding a page witch contain tabs. When clicking on the menu, which is part of the app component i want to be able to change tabs.

Originally it was easy by using:

this.app.getComponent(‘mytabs’).select(3)

Now i understand that i need to use viewchild so i tried using both:

@ViewChild(‘mytabs’) tabs:Tabs;

The ion-tab component has a #mytabs reference.

And

@ViewChild(Tabs) tabs:Tabs;

Both time the this.tabs var is undefined. My guess is that the component is not available when the app.ts component is initialized. What are my options here?

Here is my ionic info

Cordova CLI: 6.1.1
Gulp version: CLI version 3.9.1
Gulp local: Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.7
Ionic CLI Version: 2.0.0-beta.29
Ionic App Lib Version: 2.0.0-beta.16
OS:
Node Version: v4.4.0


ViewChild, undefined
#2

Any progress on this? I really need to get at the tabs from the app…

This issue

claims you only get the navcontroller from using @ViewChild

is that the intended behavior of @ViewChild? Does this mean that there is no getComponent alternative at the moment? Thanks.


#3

I think my answer here tackles this issue somewhat