Refresh a variable in another class, by tabs

I have a problem, I have two tabs,

In the first in the constructor method I perform a general search and display the results on the screen.

In the second I perform a search with a criterion of the user, and I have to show the results in the first tab.

To return to the first tab I use: (X); // where X is the position of the tab

But when you change tabs, it still shows the results that were found in the constructor.

I know I have to update the class variable of the first tab, but I do not know how, hopefully they can help me.

I would do it with a service with a common instance.

I agree with RaulGM, but in case you would like to know how to get there:

To access a public variable ‘myVar’ on a tab (with index 0 for example) that is used in the template like {{myVar}}:

this.navCtrl.parent.getByIndex(0).getViews()[0].instance.myVar = 'newValue'

will update ‘myVar’, where

let tabs = this.navCtrl.parent; // select parent of the current tab (and also parent of other tabs)
let firstTab = tabs.getByIndex(0); // select first tab (or use other index)
let renderedView = firstTab.getViews()[0].instance; // select rendered view/tab

Thanks my friend.

2017-01-16 14:13 GMT-06:00 imediasolutions <