Angularjs 使用筛选器值获取资源

Angularjs 使用筛选器值获取资源,angularjs,rest,Angularjs,Rest,我正在编写一个小的测试应用程序,可以从parse.com数据库中检索我的客户 我有以下html格式的表单 ... <body ng-app="myApp"> <div ng-controller="CustomerController"> <button ng-click="getCustomers()">Get customers</button> <ul> <li

我正在编写一个小的测试应用程序,可以从parse.com数据库中检索我的客户

我有以下html格式的表单

...
<body ng-app="myApp">
    <div ng-controller="CustomerController">
        <button ng-click="getCustomers()">Get customers</button>
        <ul>
            <li ng-repeat="customer in customers">{{ customer.name }}</li>
        </ul>
    </div>
</body>
...
工厂

app.factory('CustomersService', function($resource, myConfig) {
    return $resource(myConfig.api_url + 'Customer', {}, {
        query: { 
            method: 'GET', 
            isArray: false,
            headers: {
                'X-Parse-Application-Id': myConfig.parse_application_id,
                'X-Parse-REST-API-Key': myConfig.parse_rest_api_key
            }
        },
        create: { 
            method: 'POST',
            headers: {
                'X-Parse-Application-Id': myConfig.parse_application_id,
                'X-Parse-REST-API-Key': myConfig.parse_rest_api_key
            }
        }
    })
});
控制器:

app.controller('CustomerController', function($scope, CustomersService, CustomerService) {
     $scope.getCustomers = function() { 
         CustomersService.query().$promise.then(function(result) {  
            $scope.customers = result.results;
         });                 
     };
 });
所以当我点击我的按钮时,一切都正常工作。 但是,当我想从数据库中检索客户时,我还想按名称添加一个过滤器。 当我在《邮递员》中执行以下命令时

https://api.parse.com/1/classes/Customer?where={"name":"aaaaa"}
这是有效的,只会得到名为“aaaaa”的客户。所以我知道语法是正确的

因此,我将添加一个文本框,用户可以在其中输入customername,然后单击搜索按钮。
但是,当我点击按钮时,我如何将?where={“name”:“aaaaa”}管理成有角度的东西呢?我还想用该客户的其他列扩展过滤器。

类似的方法应该可以工作(假设所有内容都在
where
对象中)

添加一些绑定到范围对象属性的搜索字段。我们称之为
search

<label for="search_name">Name</label>
<input type="text" ng-model="search.name" name="name" id="search_name">

<label for="search_city">City</label>
<input type="text" ng-model="search.city" name="city" id="search_city">
这将创建一个查询参数,如

?where=%7B%22name%22%3A%22aaaaa%22%2C%22city%22%3A%22London%22%7D
哪个是URI编码的值

?where={"name":"aaaaa","city":"London"}

谢谢你,这就成功了!很高兴这是一个干净的解决方案,而不是实现这一点的特殊解决方法!:)
?where=%7B%22name%22%3A%22aaaaa%22%2C%22city%22%3A%22London%22%7D
?where={"name":"aaaaa","city":"London"}