How to check for an empty object in an AngularJS view
Use json
filter and compare with '{}'
string.
<div>
My object is {{ (myObject | json) == '{}' ? 'Empty' : 'Not Empty' }}
</div>
ng-show
example:
<div ng-show="(myObject | json) != '{}'"></div>
You can use: Object.keys(card).length === 0
But make sure you use it from a method of the controller as the Object
is not available in the view, like:
$scope.isObjectEmpty = function(card){
return Object.keys(card).length === 0;
}
Then you can call the function from the view:
ng-show="!isObjectEmpty(card)"