如何传递多个对象到$resource.保存在angularjs中

How to pass in multiple objects to $resource.save in angularjs

本文关键字:保存 resource 存在 angularjs 何传递 对象      更新时间:2023-09-26

目前我的正常保存看起来像这样(其中personObj被保存):

PersonService.save({ PersonId: personId }, personObj, function (data) {
                //nothing to do here
            }, function (error) {
                console.log("error in saving injury!");
                $scope.error = error;
            });

是否有一种方法可以传递另一个对象来保存?

我想让它只是一个组合对象,但我需要有两个独立的对象,因为后端函数是这样的:

public async Task<IHttpActionResult> PostPerson(int aid, Person person, Status status)
{

我可以改变后端功能,虽然我觉得好像有一些简单的角选项,我错过了

你可以这样做:

function success(response) {
  // Do whatever here.
}
function error(err) {
  console.log('error in saving injury!');
  $scope.error = error;
}
PersonService.save({ PersonId: personId }, personObj, success, error);
PersonService.save({ PersonId: personId }, potherPersonObj, success, error);