Angularjs 我是否可以使用与其他方法使用不同路由的方法创建ngResource实例?
我有一个标准ish资源,其基本路由定义为Angularjs 我是否可以使用与其他方法使用不同路由的方法创建ngResource实例?,angularjs,ngresource,Angularjs,Ngresource,我有一个标准ish资源,其基本路由定义为/documents/:id。Create/index方法的id都是nil,因此只创建了/documents的路由 return $resource(apiPath+'documents/:id', {id:'@_id'},{ index: { method: 'get', isArray:true, responseType: 'json'}, show: { method: 'get', responseType: 'json
/documents/:id
。Create/index方法的id都是nil,因此只创建了/documents
的路由
return $resource(apiPath+'documents/:id', {id:'@_id'},{
index: { method: 'get', isArray:true, responseType: 'json'},
show: { method: 'get', responseType: 'json'},
update: { method: 'put', responseType: 'json'},
create: { method: 'post', responseType: 'json'}
// search: { method: 'post', isArray:true, responseType: 'json'},
});
不幸的是,我现在需要实现“search”方法,它需要发布到/documents/search
。搜索方法实际上需要区别于index和create方法,并包含一个消息体(因此我可以包含超出正常GET请求限制的搜索条件)
如何让angular处理此问题?只需将
url
属性添加到search
objectFrom angular文档,url
–{string}–特定于操作的url覆盖。url模板与资源级url一样受支持。