Refresh TabView dynamically not working even data is binding


#1

Hello All,
I have my app mostly working using Nativescript + Angular, but some annoying small issues.
I have below TabView for the app, I want the tab title to be dynamic based on values set somewhere else in the program.
So I have, e.g., these variables “setting/about” defined in the component, and I do see the values are binding when the program starts.
But when the variable values change, the tab title is not refreshing. I have no problem refreshing the other parts of the program like ActionBar & content etc. Only this TabView is not refreshing.

 How can I enforce a refresh on the TabView here?


 <TabView androidTabsPosition="bottom" selectedIndex="0" selectedColor="blue">
...
<page-router-outlet
    *tabItem="{title: setting, iconSource: getIconSource('browse')}"
    name="settingTab">
</page-router-outlet>

<page-router-outlet
    *tabItem="{title: about, iconSource: getIconSource('search')}"
    name="aboutTab">
</page-router-outlet>

Thanks again,

Martin


#2

You may keep text in ActionBar dynamic but title in TabBar can only be static, it’s the most common use case in any app.

But if you really need dynamic tab title, you can still do it with some native code - by directly accessing the native object.


#3

Thanks for looking, Manoj!
I agree most time Tab title is static. But I need to support multiple languages, and the titles need to change per the language used.

Do you have some example or document how to handle this in native object? When you say native, it is native in iOS/Android, or nativescript objects?

Much appreciation!

Martin


#4

What I meant was it is not directly possible to keep changing tab name at run time, but you can of course have a dynamic title based on language that is set upon loading the tabview.

Do you allow user to change language within app, then it may be a problem?


#5

There is a workaround. It just requires a restart of the app after language switch, then everything including TabView will be changed. Of course it will be the best if everything changes on the fly.

Guess we can live with that.

Thank you so much, Manoj.