这可能很奇怪,但我需要使用模块的工厂方法为我的$ resource指定一些默认的POST数据.
有没有人知道如何在AngularJS中做到这一点?
编辑:
好吧,我想做这样的事情:
/**
* Module declaration.
* @type {Object}
*/
var services = angular.module("services", ["ngResource"]);
/**
* Product handler service
*/
services.factory("Product", function($resource) {
return $resource("http://someUrl", {}, {
get : {method: "GET", params: {productId: "-1"}},
update: {method : "POST", params:{}, data: {someDataKey: someDataValue}}
});
});
数据是我未来POST请求的默认数据.