我跟随damienbod's series on webapi and odata4,其中查询单个产品的odata网址将是:
http://localhost/odata/Products(5)
问题是,如何将我的$ resource url构造为angular以映射到此url?我试过了
return $resource(appSettings.serverPath + "/odata/Products(:id)"
但是当我想查询集合时会中断,在这种情况下生成的URL是
http://localhost/odata/Products()
而不是
http://localhost/odata/Products
请告知我如何为此构建$ resource url?
答案 0 :(得分:0)
您可以覆盖query
操作的网址,例如
return $resource(appSettings.serverPath + '/odata/Products(:id)', {
id: '@id' // I'm just assuming you have these default params
}, {
query: {
method: 'GET',
url: appSettings.serverPath + '/odata/Products',
isArray: true
}
});