简体   繁体   中英

Add image to ionic view header/title to tab

I have the following code:

<ion-view view-title="Dashboard">
  <ion-content class="padding">
    <h2>Welcome to Ionic</h2>
    <p>
    This is the Ionic starter for tabs-based apps. For other starters and ready-made templates, check out the <a href="http://market.ionic.io/starters" target="_blank">Ionic Market</a>.
    </p>
    <p>
      To edit the content of each tab, edit the corresponding template file in <code>www/templates/</code>. This template is <code>www/templates/tab-dash.html</code>
    </p>
    <p>
    If you need help with your app, join the Ionic Community on the <a href="http://forum.ionicframework.com" target="_blank">Ionic Forum</a>. Make sure to <a href="http://twitter.com/ionicframework" target="_blank">follow us</a> on Twitter to get important updates and announcements for Ionic developers.
    </p>
    <p>
      For help sending push notifications, join the <a href="https://apps.ionic.io/signup" target="_blank">Ionic Platform</a> and check out <a href="http://docs.ionic.io/docs/push-overview" target="_blank">Ionic Push</a>. We also have other services available.
    </p>
  </ion-content>
</ion-view>

Generated from ionic tabs starter project ( https://github.com/driftyco/ionic-starter-tabs ) and I wantd to change the header from saying "Dashboard" to just show an image. I tried this ( how to add a logo to header -bar in ionic ) but it does not work inside ionic view. So I tried adding:

  <h1 class="title"><img class="title-image" src="http://www.ionicframework.com/img/ionic-logo-white.svg" width="123" height="43" /></h1>

after:

<ion-view view-title="Dashboard">

but does not work

You could try something like this in your controller:

$scope.navTitle="<img class='title-image' src='http://www.ionicframework.com/img/ionic-logo-white.svg' width='123' height='43' />";

If not work, remove your view-title and let just the above line!

Or try this:

<ion-view>
   <ion-nav-title>
      <img src='http://www.freeiconspng.com/uploads/multimedia-photo-icon-31.png' width='123' height='43'/>
   </ion-nav-title>
</ion-view>

The second option works for me! Don't forget to remove your view-title!

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM