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

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


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

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


See the correct way with your example:

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

Regards, Nicholls


You can also use ng-template, I think that would be more efficient while run time :)

<div ng-if="!test.view; else somethingElse">1</div><ng-template #somethingElse>    <div>2</div></ng-template>

Cheers