koque
koque

Reputation: 2256

Angularjs Filter Service

I do this to filter my products by brand:

angular.extend(brandProducts,
   $filter('filter')(productDb, { 'brand': brand.name }));

How do I filter for price >= x && price <= y?

Upvotes: 0

Views: 24

Answers (1)

M0nst3R
M0nst3R

Reputation: 5293

You do not need the AngularJS filters in your JavaScript, you can simply use JavaScript array untilities as follows :

let filteredProductDb = productDb.filter((prod) => {
    return (prod.brand === brand.name && prod.price >= x && prod.price <= y);
});
angular.extend(brandProducts, filteredProductDb);

Upvotes: 2

Related Questions