Onyooo
Onyooo

Reputation: 105

Ionic: view-title and ion-nav-title issue with <script>

There is no shortage of S.O. questions, blogs, and bug reports about Ionic's view-title not updating. Solutions range from using the ion-nav-title directive instead of view-title, or set cache: false in app.js!

Yet none of these hacks worked for me. More importantly, none of the solutions I could find addressed the root problem. I started commenting-out my view. There was only one element that was causing problems: the modal.

My modals are housed in a tag like this:

<script id="user-modal.html" type="text/ng-template">

Looking for anyone who's been following this issue on why a script tag could cause this type of bug.

Concretely, is there any way I can continue having modals and not lose the title functionality?

PS: Leaving the script in and taking-out the <ion-modal-view> does not fix.

Upvotes: 1

Views: 134

Answers (1)

Onyooo
Onyooo

Reputation: 105

Still interested in why this happens, but the solution to having it working modals AND a working title bar is this:

<ion-view view-title="Profile">
  <ion-content class="dark-blue">
...
  <script id="user-modal.html" type="text/ng-template">
    <ion-modal-view>
     <ion-header-bar class="bar-dark">
Modal...
    </script>

  </ion-content>
</ion-view>

You must have the script inside of the ion-view and ion-content. While the modal will work on the outside, it will cause the tile to behave unexpectedly. Explanations welcome!

Upvotes: 1

Related Questions