0

I'm using MEAN.JS 0.4 and I need some help with Angular Resource.

My problem is this:

I want to make this API and be able to filter data server side, but I dont know how to use this Query method.

I want to do something like this:

Products.query({
  stock: 0
}, function(result){
  console.log(result)
});

This is my actual Angular service:

//Discounts service used for communicating with the discounts REST endpoints
angular.module('discounts').factory('Discounts', ['$resource',
  function ($resource) {
    return $resource('api/discounts/:discountId', {
      discountId: '@_id'
    }, {
      update: {
        method: 'PUT'
      }
    });
  }
]);

1 Answer 1

1
Discounts.query({stock: 0}).$promise
    .then(function(data) {
        products = data; })

or

products = Discount.query({stock: 0}, function() {
    //do something whith products
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.