Shijin TR
Shijin TR

Reputation: 7768

Change ionic title dynamically

I am trying to change the title of my ionic page dynamically based on a variable as follows,But it is not working,it showing an error.

<ion-view view-title='{{type == "nhs" : "NHS" : "Other"}} Prescription'  cache-view="false">

enter image description here

Upvotes: 1

Views: 671

Answers (3)

sp00m
sp00m

Reputation: 48837

I also had issues with non-hardcoded views titles. The solution I found is to use the ion-nav-title directive:

<ion-view cache-view="false">
  <ion-nav-title ng-bind="{{type == 'nhs' ? 'NHS' : 'Other'}} Prescription"></ion-nav-title>
</ion-view>

Upvotes: 2

varun aaruru
varun aaruru

Reputation: 2940

it might be because of syntax error .

condition ? expr1 : expr2

try this

<ion-view title={{type == 'nhs' ? 'NHS' : 'Other'}} cache-view="false" >

or use ng-if condition

Upvotes: 2

Ved
Ved

Reputation: 2701

<ion-view title="{{(type == 'nhs') ? 'NHS' : 'Other'}} Prescription"  cache-view="false">

Upvotes: 1

Related Questions