我定义了一个工厂,返回一个$resource
:
myApp.factory('Region', function($resource) {
return $resource(baseUrl + '/templates/:templateId/regions/:regionId', null, {
query: {
method: 'GET',
isArray: false
},
update: {
method: 'PUT'
}
});
});
正如你所看到的,一个区域是一个模板的子资源,我已经定义了端点/templates/:templateId/regions/:regionId
。
我希望保存新区域时出现问题。如何指定templateId
将区域保存到?这里是我的片断:
$scope.save = function() {
if ($scope.mode === 'edit') {
// TODO
} else {
Region.save($scope.region, function(success) {
$state.go('app.templateList')
});
}
};
在所有其他资源我有我刚刚用Model.save($scope.model);
,我不知道如何指定其他URL参数和角文档似乎并没有掩盖它。