angularjsionic-frameworkng-showng-hide

ng-show ng-hide not working


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.


Solution

  • $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;