Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I generate title dynamically on ionic framework?

I use ionic pet template. I have a question about pet-detail page, if I would like to have a dynamic title on header, it will not show anything until I reload the page (using web browser), but I think it doesn't make sense since I would like to make an app. Does I miss anything? what can I do?

here is my code as below:

<ion-nav-bar class="bar-positive">
<div class="buttons" ng-controller="BackCtrl">
    <a class="button button-icon icon ion-chevron-left" ng-click="$back()"></a>
</div>
<h1 class="title"> {{ current_pet.name }} </h1>

..

like image 293
GaGa Avatar asked Apr 25 '14 09:04

GaGa


2 Answers

If you happen to be using ion-view, use this:

<ion-nav-title>
    {{ PageTitle }}
</ion-nav-title>

And put it outside your ion-content.

like image 77
dk123 Avatar answered Nov 17 '22 05:11

dk123


In my app I've used this:

<ion-view title="{{Properties.Title}}">

Where Properties is a object on my scope(I have sort of a master controller) where I "override" on each "inner controller".

like image 28
Amir Popovich Avatar answered Nov 17 '22 06:11

Amir Popovich