我定義了一個工廠,返回一個$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參數和角文檔似乎並沒有掩蓋它。