Reputation: 11
<div class="emptyMessage" ng-show="{{ToBuy.Items.length}}==0" > Everything is bought! {{ToBuy.Items.length}} </div>
I wanted the above Div tag to not show when my ToBuy.Items array has some elements in it. The Div tag should appear only when there are no Items in ToBuy.Items array has no elements.
When I removed all elements from the array (Tobuy.Items), the expression simply shows ng-show="0==0" and the Div Tag doesn't show up on the web page.
Any help greatly appreciated.
Upvotes: 1
Views: 1154
Reputation: 31
Try to use ng-hide
ng-hide='ToBuy.Items.length'
or
ng-hide='ToBuy.Items'
both should work i think.
Upvotes: 1
Reputation: 222582
Remove the expression inside the ng-show,
<div ng-controller="MyCtrl">
<div ng-show="ToBuy.Items==0"> Everything is bought! {{ToBuy.Items.length}} </div>
</div>
Upvotes: 1
Reputation: 10538
ngShow
expects an expression, so you do not want to put curly braces in it. Try the following:
ng-show='ToBuy.Items.length == 0'
I'd recommend making this expression a property on your controller instead of checking ToBuy.Items.length == 0
. Business logic belongs in the controller, not in the view.
Upvotes: 1