How to show/hide if variable is null

I'm wanting to show/hide a div based on whether a variable is null or not.

<div ng-show="myvar"></div>

Note: the variable in my case is an object.

A very simple question, but I can't seem to make it work.

Thanks.


<div ng-hide="myvar == null"></div>

or

<div ng-show="myvar != null"></div>

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;

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.