how to check for null with a ng-if values in a view with angularjs?

Patrioticcow picture Patrioticcow · May 9, 2014 · Viewed 212k times · Source

i have this situation

<div ng-repeat="test in current">
    <div ng-if="test.view == null">
        <i class="icon ion-checkmark"></i>
    </div>
</div>

but test.view== null doesn't work, neither just checking for test.view or test.view == ''

any ideas?

thanks

edit:

in the loop, sometimes test.view, has a value sometimes is NULL if i do:

<div ng-if="!test.view">1</div>
<div ng-if="test.view">2</div>

i will only see 1

Answer

Lucas Polonio picture Lucas Polonio · May 9, 2014

You should check for !test, here is a fiddle showing that.

<span ng-if="!test">null</span>