Azmy
Azmy

Reputation: 203

Finding the number of records returned from a conditional statement in ember

I have a unless condition and I want to find out the number of records that satisfies this unless condition.

Can do this or not in ember?

EDIT:

{{#each model.orderParts as |newCart|}} 

  {{#unless newCart.isGeneric}}
    <div class="card-wrapper col-lg-12 col-md-12">
<div class="col-lg-2 col-md-2">
    <div class="order-id">{{newCart.partNumber}}</div>
    {{#if (gte newCart.promiseQty newCart.quantity)}}
    <div class="order-status delivered">{{env.APP.StockAvailable}}</div>
    {{else}} {{#if (gt newCart.promiseQty '0'(and (lt newCart.promiseQty newCart.quantity)))}}
    <div class="order-status delivered">{{env.APP.LowInStock}}</div>
    {{else}} {{#if (eq newCart.promiseQty '0')}}
    <div class="order-status delivered">{{env.APP.OutofStock}}</div>
    {{/if}} {{/if}} {{/if}}
</div>
<div class="col-lg-3 col-md-3">
    <div class="item-header">Delivery Date</div>
    <div class="item-data">{{newCart.deliveryDate}}</div>
</div>
<div class="col-lg-2 col-md-2">
    <div class="item-header">Required Qty.</div>
    <div class="item-data">
        {{increse-required-quantity incresedQuantity=newCart.quantity}}
    </div>
</div>
<div class="col-lg-2 col-md-2">
    <div class="item-header">Unit Price</div>
    <div class="item-data">{{newCart.unitPrice}}</div>
</div>
<div class="col-lg-2 col-md-2">
    <div class="item-header">Total Price</div>
    <div class="item-data">{{newCart.partTotalPrice}}</div>
</div>
{{/unless}}  {{/each}}

what i want is to find out the number of records that satisfy this condition

Upvotes: 1

Views: 75

Answers (1)

Ember Freak
Ember Freak

Reputation: 12872

genericFalseCount: Ember.computed.filterBy('model.orderParts','isGeneric',false)

The above computed property will give you the count.

Upvotes: 1

Related Questions