Search code examples
javascriptangularjsangularjs-directiveangularjs-scope

Angularjs dynamic ng-if data binding in span


I have this Angular expression in my view:

 <span ng-if="{{list.StoreList ? (list.StoreList.length ' Products)' : '(0 Products)'}}"> </span>

So if I have any items in the StoreList then I'll display the count, otherwise I'll just show 0 products.

I'm getting unexpected expecting error from Angularjs.

How can I solve this?


Solution

  • Try with:

    <span ng-if="list.StoreList">{{'(' + list.StoreList.length + ' Products)'}}</span>
    <span ng-if="!list.StoreList">(0 Products)</span>