Javascript angularjs$资源$保存未过帐数据

Javascript angularjs$资源$保存未过帐数据,javascript,angularjs,Javascript,Angularjs,api/profile/:accountname/:profilename 我正在尝试使用$resource以restful方式使用我的api。我的数据模型是:每个帐户都有一个配置文件列表,这些配置文件应该有GET、POST和PUT。但是,我通常不会只获得一个概要文件,而是所有概要文件。如果我没有获得profilename,那么将返回整个帐户 var re = $resource('/api/profile/:accountname/:profilename', { accountname :

api/profile/:accountname/:profilename

我正在尝试使用$resource以restful方式使用我的api。我的数据模型是:每个帐户都有一个配置文件列表,这些配置文件应该有GET、POST和PUT。但是,我通常不会只获得一个概要文件,而是所有概要文件。如果我没有获得profilename,那么将返回整个帐户

var re = $resource('/api/profile/:accountname/:profilename', { accountname : '@accoutname', profilename : '@profilename' });
var r =  re.get({ accountname: 'leo', profilename: 'qwe' }, function (data ) {
        //change some properties on r.
        //ideally, I should be able to put r is a $scope, and have two-way binding working and $save the changes to the server.
        r.$save({ accountname: 'leo', profilename: 'qwe' });
    });
此代码的问题是没有向服务器发布数据。我不得不在$save方法中再次传递参数,这已经够令人沮丧的了。它不应该记住它的参数吗,因为我已经在get方法中指定了它,我从中获得了调用$save的对象。如果有更好的方法,请告诉我。当我检查回调中的数据时,这是我对服务器的期望,但现在我只需要能够在调用$save时将其本身发布到服务器。官方文档是如此之小,以至于不清楚每个方法的取数和返回数,它需要很多改进

编辑: 我解决了没有数据发布到服务器的问题,它在评论中。谜团仍然存在,我必须在$save方法中提供参数,而官方文档没有

编辑2:
谜团已解开,请参阅注释。

我的
$resource
使用
.save()
而不是
$save()
。此外,它还返回一个
$promise
@Tony文档是否错误?它使用了利奥的确切模式,包括$save:Ahah!看这里:我还注意到save调用正在
r
上执行,它不是
$resource
@Tony:r与data是同一个实例。