Sage
Sage

Reputation: 189

how to add a logo to header -bar in ionic

I am trying to add a logo in the center of my header bar using Ionic. Any advise on how to do it?

Here is my code

<ion-nav-bar class="bar-light">
<!--Logo-->
<ion-nav-buttons >
<img class="title" src="https://s3-us-west 2.amazonaws.com/s.cdpn.io/139144/sp_symbol_option2_1.png">
</ion-nav-buttons>
<ion-nav-buttons side="left">
<!--Left icons-->
<button class="button button-icon button-clear ion-navicon" ng-click="toggleLeft()"> 
</button></ion-nav-bar>

Upvotes: 15

Views: 44649

Answers (6)

Pritam Banerjee
Pritam Banerjee

Reputation: 18968

The following can also be done:

<ion-view  id = "yourHeader">
    <ion-nav-title>
        <div id = "title">YOUR TITLE</div>
        <img src="img/Message.png" class = "peers_msg_img">
        <img src="img/Notification.png" class="peers_profile_img">
        <img src="img/Peers.png" class="peers_alert_img">
     </ion-nav-title>
     <ion-content>
       //Some Content
     </ion-content>
</ion-view>

The following directive is the key:

<ion-nav-title>

Upvotes: 0

Sanketh T
Sanketh T

Reputation: 21

Put the desired image in "www/img" folder in your app. Then use the below code in index.html

<h1 class="title"><img class="title-image" src="img/mylogo.png" width="123" height="43" /></h1>

Upvotes: 2

Abhijit
Abhijit

Reputation: 33

<ion-view>
    <ion-nav-title>
            <img alt="Company Logo1" height="40" src="img/logo-07.png">
            <img alt="Company Logo2" height="40" src="img/logo-08.png">
    </ion-nav-title>
</ion-view>

Change the image height and src according to your taste. :)

Upvotes: 2

Enrique Oriol
Enrique Oriol

Reputation: 1730

Considering that you are using a nav bar, you should use ion-nav-title. Here's an example:

<ion-nav-bar align-title="center">
</ion-nav-bar>
<ion-nav-view>
  <ion-view>
    <ion-nav-title>
      <img src="logo.svg">
    </ion-nav-title>
    <ion-content>
      Some super content here!
    </ion-content>
  </ion-view>
</ion-nav-view>

Upvotes: 3

SM3RKY
SM3RKY

Reputation: 1597

I have done this simply by the following:

In my template <ion-view title="{{pageTitle}}">

and in my controller $scope.pageTitle = "<img src=\"img/logo-290-90.png\">";

Upvotes: 5

LeftyX
LeftyX

Reputation: 35597

How about doing something like this:

<ion-header-bar align-title="center" class="bar-positive">
  <div class="buttons">
    <button class="button" ng-click="doSomething()">Left Button</button>
  </div>
  <h1 class="title"><img class="title-image" src="http://www.ionicframework.com/img/ionic-logo-white.svg" width="123" height="43" /></h1>
  <div class="buttons">
    <button class="button">Right Button</button>
  </div>
</ion-header-bar>

You can have a look at this plunker as well.

Some extra info in their forum.

Upvotes: 21

Related Questions