   transclude: true
   scope:
     bpNavbarTitle: '@'
-  compile: (elem, attrs, transcludeFn) ->
-
-    getTitleFromState = (state) ->
+  controller: ($scope) ->
+    $scope.getTitleFromState = (state) ->
       state.data?.title or
       state.name.charAt(0).toUpperCase() + state.name.slice(1)
 
+  compile: (elem, attrs, transcludeFn) ->
     ios = if bpConfig.platform is 'android' then no else yes
-
     (scope, element, attrs) ->
       state = $state.current
 


            unless scope.navbarTitle then $timeout ->
              difference = $scndAction.outerWidth() - $frstAction.outerWidth()

              if difference isnt 0 and $frstAction.length
                $spacer = angular.element("
                  <div style='
                    -webkit-box-flex:10;
                    max-width:#{Math.abs(difference)}px
                  '>")
                if difference > 0
                  $spacer.insertBefore $title
                else if difference < 0
                  $spacer.insertAfter $title
            , 0

          else


        if state.data?.up? and not attrs.bpNavbarNoUp?
          upState = $state.get state.data.up
          upTitle = scope.getTitleFromState upState
          $up = $compile("
            <bp-action class='bp-action-up' bp-sref='#{upState.name}'>#{
              upTitle
