Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ng资源查询返回所有记录_Javascript_Angularjs_Angularjs Ng Repeat_Odata - Fatal编程技术网

Javascript ng资源查询返回所有记录

Javascript ng资源查询返回所有记录,javascript,angularjs,angularjs-ng-repeat,odata,Javascript,Angularjs,Angularjs Ng Repeat,Odata,我有这样的ng资源设置 (function () { 'use strict'; var storeCommandServiceRoot = '/api/StoreCommandsRest/:id'; angular.module('common.service') .factory("storeCommandResource", ["$resource", "appSettings", storeCommandResource]) function storeCommandResource(

我有这样的ng资源设置

(function () {
'use strict';
var storeCommandServiceRoot = '/api/StoreCommandsRest/:id';

angular.module('common.service')
.factory("storeCommandResource", ["$resource", "appSettings", storeCommandResource])
function storeCommandResource($resource, appSettings) {
    return $resource(appSettings.serverPath + storeCommandServiceRoot, { id: '@id' },
           { "update": { method: "PUT" } });
}}());
我试图通过查询一个名为“Serial”的整数属性来获取记录

        function getStoreCommandsBySerial() {
        var storeCommandGet = storeCommandResource.get({ Serial: 3 });
        storeCommandGet.$promise.then(function (response) {
            debugger;
        });
    }
但作为回应,我得到了所有的记录。我只希望是Serial=3的记录。 发送过来的url看起来像


在服务器端,它是一个oDataController,具有基于REST的功能

似乎您的名称与参数不一致。在工厂中,您有
{id:'@id'}
,但在控制器中,您使用:
storeCommandResource.get({Serial:3})

尝试更改
storeCommandResource.get({Serial:3})
to
storeCommandResource.get({id:3})
此外,您的storeCommandServiceRoot应该是“/api/StoreCommandsRest/?id=:id”

如果您打算在url中保留“序列号”,请确保将其余的更改为“序列号”,而不是id和序列号混合