ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

[Feature Request] New directive to inject content inside the NavBar

Open jgoux opened this issue 12 years ago • 7 comments

Hello, I'm trying to initialize a view with an input with some behaviour inside the header. As my view is in a tab, I have to use directives like

<ion view="title">

or

 <ion-nav-buttons side="right">

to modify the navbar. It would be great to have a directive which allow us to inject html content inside the parent navbar like :

<ion-nav-content>
        <div id="search-box" class="bar bar-header item-input-inset">
        <div class="item-input-wrapper">
            <i class="icon ion-search placeholder-icon"></i>
            <input type="search" placeholder="Rechercher..." ng-model="search.input">
            <i ng-if="search.input.length > 0" ng-click="clearSearch()" class="icon ion-close placeholder-icon"></i>
        </div>
    </div>
</ion-nav-content>

We can imagine that this directive could replace the navbar title with the content in it, and all the behaviour injected would be linked with the current controller. If you have another solution to inject content with behaviour in the navbar, don't hesite to share ^^

jgoux avatar Apr 25 '14 09:04 jgoux

What do you think @mlynch @adamdbradley?

ajoslin avatar Apr 29 '14 16:04 ajoslin

I see, so a more generic way to just clobber the entire automation of the nav bar?

Why not just use a header bar in this case and hide the nav bar? On iOS I don't think you can inject arbitrary content into a nav bar...

Not opposed, just want to make sure it's worth it.

mlynch avatar Apr 29 '14 20:04 mlynch

Initially I'm thinking we may have some scoping issues, but I haven't tried something like this out to be sure. This is a custom nav bar and with complicated content it might be better to start with just a header bar.

adamdbradley avatar Apr 30 '14 02:04 adamdbradley

@jgoux You could actually just put any content in the <ion-nav-bar> with an ng-if, and use ng-class to hide the title when desired.

<ion-nav-bar ng-class="{'hide-title': customContentShown()}">
  <div ng-show="customContentShown()">
    Hi, I'm custom!
  </div>
</ion-nav-bar>
.bar.hide-title .title {
  display: none;
}

ajoslin avatar Apr 30 '14 21:04 ajoslin

Moving feature requests from GH Issues to Trello. Please continue the discussion and vote for this and other issues that are important to you here: https://trello.com/c/ngdLVZIV/5-new-directive-to-inject-content-inside-the-navbar

perrygovier avatar Jul 28 '14 20:07 perrygovier

I vote for the customization function. I tried to add a button-bar to the ion-nav-bar, which turns out to be nightmare. Right or wrong, using ng-if is not working perfectly, the left side button goes to right side and if there is right side buttons, left one disappeared. This seems to be caused by the order the elements are added to the header during directive handling, but it is too much to hack. The adding of new directives is very very appreciated!

rosefirefish avatar Aug 11 '14 16:08 rosefirefish

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

ionitron-bot[bot] avatar Sep 06 '18 13:09 ionitron-bot[bot]