Can't dynamically change title in ion-tab

Hi,

I’m having trouble with dynamically changing the title attribute of the ion-tab tag. I want to change the title with javascript, because the title has to show the date of today and some days earlier.

I am using the sidemenu template from Ionic, which I changed a bit. In browse.html I have added the ion-tabs and ion-tab interface, this is working perfectly. I have given the ion-tab an ID “today”, like this:

Using a button i’m calling a javascript function myFunction(). In index.html I have placed this javascript code:

The function is being called, but the title doesn’t change.

I’ve also tried this:
document.getElementById(‘today’).setAttribute(‘title’, ‘test 1’);
But no results. I’ve also tried this:

var n = document.getElementById(‘today’).title;

But n stays empty.

I can’t figure out what is the problem here. Can anybody help me with this?

Greetings,
Michel

Use Angular! xD

Regards, Nicholls

Thanks for your reply, but could you be a little more specific? Thanks!

Something like set

$scope.dynamic_title = “Foo”;</code

in your tabs controller and use that variable in your template, like

<ion-tab title=“{{dynamic_title}}”>

1 Like

Hi Emily, thanks! This is what I need I think!

I’ll let you know if it works.

Greetings,
Michel

Hi Emily, it works, thanks!

Awesome, you’re welcome!

1 Like