I\'m wanting to show/hide a div based on whether a variable is null or not.
Note: the variable in
To clarify, the above example does work, my code in the example did not work for unrelated reasons.
If myvar is false, null or has never been used before (i.e. $scope.myvar or $rootScope.myvar never called), the div will not show. Once any value has been assigned to it, the div will show, except if the value is specifically false.
The following will cause the div to show:
$scope.myvar = "Hello World";
or
$scope.myvar = true;
The following will hide the div:
$scope.myvar = null;
or
$scope.myvar = false;
<div ng-hide="myvar == null"></div>
or
<div ng-show="myvar != null"></div>
In this case, myvar should be a boolean value. If this variable is true, it will show the div, if it's false.. It will hide.
Check this out.