AngularJS - Hiding value based on null and empty array

Oam Psy picture Oam Psy · Aug 27, 2014 · Viewed 12k times · Source

I am trying to perform an ng-hide when a value is either null or an empty array (in Firebug, this appears as []).

I can carry out the null via:

ng-hide="myData.Address == null"

However when i try:

ng-hide="myData.Address == null || myData.Address == []"

The value still appears.

Answer

Amir Popovich picture Amir Popovich · Aug 27, 2014

Try this:

ng-hide="myData.Address == null || myData.Address.length == 0"