# Set ion-nav-bar title from a directive

**URL:** <https://forum.ionicframework.com/t/set-ion-nav-bar-title-from-a-directive/22493>\
**Category:** ionic-v1\
**Created:** [May 6, 2015, 12:45pm UTC](https://forum.ionicframework.com/t/set-ion-nav-bar-title-from-a-directive/22493 "2015-05-06T12:45:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikehaas763](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mikehaas763/32/81926_2.png) [@mikehaas763](https://forum.ionicframework.com/u/mikehaas763)\
**Post date:** [May 6, 2015, 12:45pm UTC](https://forum.ionicframework.com/t/set-ion-nav-bar-title-from-a-directive/22493/1 "2015-05-06T12:45:57Z")

</div>

I’m building an EmptyContent directive so that I have an empty state that can be reused throughout my app. It is shown based on a condition otherwise the main view is shown. The directive shows some basic content. I would also like for it to set the title in ion-nav-bar.

I can’t just put ion-view in my directive as the root element because then using view-title on the ion-view element does not actually set the title. I suspect this is because with my directive wrapping ion-view it is no longer a child element of ion-nav-view. If I remove ion-view directly from my directive and put it in the parent template around my directive then I would have to use ion-nav-title from within my directive to set the title but that will also not work because ion-nav-title needs to be an immediate descendant of ion-view.

Any suggestion as to how I can safely and reliably set the ion-nav-bar title from within a directive?

An example showing what I want to do… not how it can/should actually be done 😄

```auto
<!-- my-directive in this example wraps its own ion-view. However, the title is always set to "A title" no matter what isEmptyShown evaluates to. -->
<my-directive ng-if="isEmptyShown"></my-directive>
<ion-view ng-if="!isEmptyShown" view-title="A title"></ion-view>

```
