ngResource appends POST parameters to url

99封情书 提交于 2019-12-05 14:09:49

I think you're conflicted on how to use $resource. You should create $resource instances as if they were models and set the attributes on the object that you want to POST.

With your Apples $resource defined as above:

var apple = new Apples();

apple.color = ...
apple.name = ...
apple.tree_id = ...

apple.$create()

Or you could just use the $resource class directly:

Apples.create({
    apple.color: ...
    apple.name: ...
    apple.tree_id: ...
});

Finally, $resource has the built-in $save() that uses POST which you can use instead of creating a custom $create() action.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!