Get ion-view title attribute to display in ion-item text


#1

Hello, I am new to Ionic and I cannot seem to figure out how I can get a ion-view title attribute.
Example:
<ion-view title="Page 2 Title" id="page2" style="">
I have tried the following: {{page2.title}}, without success.

  • How can I do it, and what am I missing, I am inserting it like this:
<ion-item class="item-icon-right" id="menu-list-item2" ui-sref="menu.page2()" menu-close="" style="">{{page2.title}}</ion-item>

I an also wondering if it is possible to grab the title automatically by detecting the ui-sref and getting the title attribute that way also. I am very surpriced that I cannot find anyone with the same question as I.
Thank you in advance.


#2

Since nobody has answered is this then impossible to grab/read an ion view attribute from another page?


#3

In your controller, declare a scope variable like
$scope.page2.title and fill it up.

and then use it wherever you want. It should work.
Do you have a codepen for this