Hide content only in Home

Hi! I’m trying to hide a header buttons if is iPad or if is Home page. I’m trying with $ionicHistory but this return undefined.

JS:

.controller('HeaderButtonsCtrl', function($scope, $ionicHistory) {
    alert($ionicHistory.currentTitle());

    $scope.hideButtons = true;

    if( ionic.Platform.isIPad() ) {
        $scope.hideButtons = false;
    }
})

HTML:

    <ion-nav-buttons side="right">
        <div class="contenedor-botones-header" ng-controller="HeaderButtonsCtrl">
            <button ng-hide="hideButtons" class="button btn-notificaciones ng-hide" ng-click="showNotifications()"></button>
            <span ng-hide="hideButtons" class="header-separador"></span>
            <button ng-hide="hideButtons" class="button btn-chat ng-hide" ng-click="showChat()"></button>
        </div>
    </ion-nav-buttons>
</ion-nav-bar>

There is a way to know what page I’m and hide this buttons?
Thanks!

Note: I’m having a Login page before Home.

You can set an extra data attribute on the home state, e.g.:

$stateProvider
  .state('home', {
    // ...
    data: {
        hideHeaderButtons: true
    } 
  })

Then you will access to that via:

$state.current.data.hideHeaderButtons

Which you can inject into your HeaderButtonsCtrl controller.

Thanks! This make sense.

I make an implementation and works ok in Home, but I have a problem when I’m not in home page, I get an error of undefined.

This my HeaderButtonsCtrl controller:

.controller('HeaderButtonsCtrl', function($scope, $state) {
    // Show / Hide buttons
    $scope.hideButtons = true;

    if( ionic.Platform.isIPad() ) {
        $scope.hideButtons = false;
    }

    if ( $state.current.data.hideHeaderButtons !== undefined ) {
         if ( $state.current.data.hideHeaderButtons ) {
             $scope.hideButtons = true;
             console.log($state.current.data.hideHeaderButtons);
         }
     } 
})

Sorry if this question is very basic. I’m a beginner in the Ionic and Angular world.

Probably the $state.current.data is undefined. So you need to check for that:

if ( $state.current.data && $state.current.data.hideHeaderButtons ) {
   $scope.hideButtons = true;
}