How to check if a scope variable is undefined in AngularJS template?

angularjs, angularjs-ng-show

Solution

Here is the cleanest way to do this:

<p ng-show="{{foo === undefined}}">Show this if $scope.foo === undefined</p>

No need to create a helper function in the controller!

Problem

How to check if a scope variable is undefined? This does not work: ``` <p ng-show="foo == undefined">Show this if $scope.foo == undefined</p> ```

Original source

Related problems