0

I'm trying to hide a section when a variable is null.

<ion-item class="item-avatar calm" id="detalleDeCita-list-item29" ui-sref="volare2.perfilDelAsesor" ng-show="asesor" >
    <h2calm>Asesor {{asesor}} 
      <p>Ver perfil</p>
    </h2calm>
  </ion-item>

Controller

 $scope.asesor = $stateParams.asesor;

and it comes null. It shows the html segment no matter the value of $scope.asesor.

The same happens if use ng-hide or ng-if.

I've tried every combination possible but no matter what, it doesn't work.

Murhaf Sousli
  • 12,622
  • 20
  • 119
  • 185

1 Answers1

1

$stateParams params are always strings. "true" == true, but also "false" == true. You need to coerce the value to boolean somehow. Try this :

 $scope.asesor = !!$stateParams.asesor;
Akashii
  • 2,251
  • 3
  • 17
  • 29