【问题标题】:Want to use angularjs resource object with action method想用 angularjs 资源对象和 action 方法
【发布时间】:2015-04-20 22:54:27
【问题描述】:

我想使用 angularjs 资源对象对我的服务器进行搜索查询,并且我已经编写了这样一个资源对象;

app.factory('EcriDeviceListService', function ($resource) { var URL = "http://localhost:60766/api/EcriDeviceLists/:id/:queryText"; return $resource(Url, { id: '@Id' },{ update: { method: 'PUT' },'search': { method:'GET', {queryText:''}}) });

我想用这段代码进行这样的搜索查询;

EcriDeviceListService.search({queryText:'abc'})

http://localhost:60766/api/EcriDeviceLists/queryText=abc"

我应该如何配置我的资源对象。

谢谢。

【问题讨论】:

    标签: angularjs action


    【解决方案1】:

    你应该像这样配置$resource对象:

    $resource('http://localhost:60766/api/EcriDeviceLists/:id/:queryText', { 
            id: '@Id', 
            queryText: '' 
        }, { 
            update: { 
                method: 'PUT' 
            }, 
            search: {
                method: 'GET'
            }
        });
    

    【讨论】:

      猜你喜欢
      • 2013-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-10
      • 2014-09-23
      • 1970-01-01
      • 2012-11-01
      • 2019-02-17
      相关资源
      最近更新 更多