-1

For example I have something like this:

{
  status: {
    text: "New",
    date: "22.06.12"
  }
}

Factory to interact with RESTfull lookes like

(function(){
    'use strict';

    angular.module('app')
        .factory('Orders', Orders);

    Orders.$inject = ["$resource"];
    function Orders($resource){
        return $resource('Orders/:id', {id: '@id'});
    };

})();

And I want to find all records with status.text = "New"

 $scope.orders = Orders.query({status:{text:"Tru"}});

not work at all

$scope.orders = Orders.query({status[text]:"Tru"}});

return all records....

How to put object property to query?

g_arc
  • 9
  • 4

1 Answers1

0

Looks like you trying to interact with no-RESTful backend with $resource service. $resource is designed for REST, for other situations is better to use standard $http-service, like that:

$http({
  url: 'http://ololo.com',
  method : 'get',
  params : {status: 'tru'}
}).success(function(response){
  $scope.filteredOrder = response;
});

Use 'data' for 'post'.

Dmitry Lobov
  • 313
  • 1
  • 10
  • I using Restful.. But even in such way $http({ url: 'http://ololo.com', method : 'get', params : { status: {text: "New"} } }) would not work... – g_arc Jan 09 '16 at 15:26
  • I'd made some refactoring in my answer. Looks like problem is on backend, check there, are all of params came correctly. Remember, some backends, whitch not supports native JSON (like Apache or some Python-based), requires to convert JSON to string. Try to send params this way: params : JSON.stringify({status: 'tru'}) – Dmitry Lobov Jan 09 '16 at 15:37