Angularjs 角度js嵌套资源

Angularjs 角度js嵌套资源,angularjs,web-services,resources,Angularjs,Web Services,Resources,我想配置一个角度$资源。这个$resource应该允许调用远程web服务 // Gets all the nested-resources of a parent-resource 1) GET /parent-resource/nested-resources // Gets a nested-resource by id 2) GET /nested-resource/{id} // Create a nested resource 3) POST /nested-resource 在

我想配置一个角度$资源。这个$resource应该允许调用远程web服务

// Gets all the nested-resources of a parent-resource
1) GET  /parent-resource/nested-resources
// Gets a nested-resource by id
2) GET  /nested-resource/{id}
// Create a nested resource
3) POST /nested-resource
在我的场景中,我希望使用第一个web服务检索所有嵌套资源。当用户修改嵌套资源时,将使用第三个web服务保存嵌套资源

var NestedResource = $resource('/nested-resource/:id');
Publishable.prototype.isNew = function() {
    return this.id === undefined;
};
... lot of functions...
此配置对于第二个和第三个web服务很有效,但是如何配置资源以使用第一个web服务呢。有几个函数在嵌套的资源原型上注册,我希望避免创建特定的$resource

Publishable.prototype.getByParentId = function(parentId) {
    // ??        
}

在资源上创建自定义操作,如下所示:

var NestedResource = $resource('/nested-resource/:id',,
    { action: "getAll",
      method: "GET",
      isArray: true,
      url: '/parent-resource/:parentId/nested-resources'
    });
现在,您应该能够执行以下操作:

var allItems = NestedResource.getAll({parentId: 1});

检索parentId 1的列表。

谢谢。如何指定父资源id?请参阅我的更新-我不确定我现在是否理解您的问题,但希望这能有所帮助。这正是我想要的。谢谢