Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using linq-like expression in angular ng-show

I have an array of trades:

var trades = [
    {
        orders: [
            {
                confirmed: true
            },
            {
                confirmed: false
            }
        ]
    }
]

I would like to use a linq-like expression in my directive expression (in this case an ng-hide): So, something like (warning: hybrid c#-angular code below):

<div ng-repeat="trade in trades">
      <span ng-hide="trade.orders.any(order => !order.confirmed)">Confirmed</span>
</div>

is there any way to write the .any(order => !order.confirmed) using javascript?

Thanks in advance.

like image 740
pQuestions123 Avatar asked Dec 20 '22 06:12

pQuestions123


1 Answers

Angular doesn't have this, but there are some libraries you can use alongside it which provide LINQ-like features, including .any():

  • https://lodash.com/
  • http://underscorejs.org/
like image 112
Val Avatar answered Dec 21 '22 20:12

Val