Ionic nav/header bar buttons not working!


My buttons in the nav bar are not working. This includes:

  1. create item (top left corner) should lead to new inputs page
  2. clicking on app name should lead to main page
  3. clicking on user name should go to another page

I tried shifting the ions-nav-bar, ion-nav-view or ion-views around to changing states from href to ui-sref and nothing works. I think i need a new controller for a new post?

The examples on the website are also very very brief. Please kindly help?


The end header now looks like this.

This is the navbar html

  <ion-view ng-controller="NavCtrl">
    <ion-nav-buttons side="left" ng-submit="submitPost()">
       <button class="button button-icon ion-compose" href='/tab/newpost'></button> 
    *<!-- the furthest I got was to shift down submitPost() as ng-click="submitPost() to the ion-nav-button but it does not go to the new page -->* 
       <button class="button-clear" href='#/tab/posts'><b>MyApp</b></button>
          <ion-nav-buttons side="right">
            <button class="button-clear" href="#/users/{{ currentUser.username }}">
              <img ng-src="{{ currentUser.md5_hash }}" class="nav-pic"/>{{ currentUser.username }}
            <button class="button button-icon ion-log-out" ng-click="logout()"></button>

This is the stateProvider

.state('tab.posts', {
  url: '/posts',
  views: {
    'tab-posts': {
      templateUrl: 'templates/tab-posts.html',
      controller: 'PostsCtrl'

.state('tab.newpost', {
      url: '/newpost',
      views: {
          templateUrl: 'templates/tab-newpost.html',
          controller: 'NavCtrl'

This is the controller

app.controller('NavCtrl', function ($scope, $location, Post, Auth) {
    $ = {url: 'http://', title: ''};
    $scope.submitPost = function () {
      Post.create($ (postId) {  
        $ = {url: 'http://', title: ''};
        $location.path('/posts/' + postId);            

    $scope.logout = function () {
      $location.path('/auth/login');   <!-- have to click twice to logout -->

This is the index.html file

  <body animation="slide-left-right-ios7">
        <div ui-view>
          <ion-nav-bar class="bar-stable nav-title-slide-ios7"></ion-nav-bar>


Hmm this maybe come from the docs not being clear.

So you don’t need to put an ion-nav-bar in your ion-view if you already have one in your index.html.

Take a look at this codepen

Also, remove the div with the ui-view, it will mess your project up.


Thanks Mike for the reply.

The formatting cleared a fair bit but buttons are still not working.

I noticed because I was missing a controller to bring me to another page on a click of a button. I searched around but nothing mentioned on how to combine ui-router and ng-click (or other methods i should use).

I understand some stuff may be outside of Ionic but if u do have a suggestion/s, Ill be happy to hear :slight_smile: esp on the controller codes.


 <ion-nav-buttons side="left">
        <button class="button button-icon ion-compose" ng-click="go('/tab/newpost')"></button>
        <button class="button-clear" ui-sref='tab.posts'><b>MyApp</b></button>

This is the controller

app.controller('NewCtrl', function($scope, $state, $location, $ionicPopup, $timeout) {
	$scope.go = function() {

Some how Im on ui-router but none of the ui-sref are working…its very odd.


If you need to use ng-click with ui-router, you should able to do this

$scope.nav = function() {

Can you put together an example codepen? 


Ok here you go, Im not too sure how the pen works so perhaps you could give some pointers. When i click on the button, the posts page navbar dissappears but is not replaced by anything while the body has no changes.

Are there any better ways of doing this? I tried [a href bla] but it isnt working

Just as a reference and contrast, this guys shows that using all 3 ways, the link can be done so Im not sure whats missing in mine?
3 examples for routing on Codepen


Maybe the issue is with your Post and Auth. After removing them and your code and just testing with a simple alert, things worked fine.


Hi Mike,
by removing Post and Auth, do you mean entirely removing them from the controller? or just the dependencies?

Post is defined in a js file for posting a new item while Auth is defined in yet another js file for authentication purposes.


The dependencies themselves. If there’s an issue in one of them, it can throw the whole project off.


Its really odd, it still doesnt work even after tweaking the dependencies as you mentioned. Any other ways I can do further testing?


Open up the javascript console and see what errors are coming in


ctrl shift J doesnt show any errors in the console tab, neither does Batarang.

Not removing Auth and Post, the test message that you devised pops up on my local version which meant it worked!. So possibly it might be the $scope.create portion to replace the alert that might be wrong?

$scope.create = function() {

while the button is

<button class="button button-icon ion-compose" ng-click="create()"></button>


To help visualize better.

This is the pic for before and after the button click.

  • buttons went missing
  • url did change
  • the post list remains unchanged but its supposed to transit to a new html page