【问题标题】:How to pass in multiple objects to $resource.save in angularjs如何在angularjs中将多个对象传递给$resource.save
【发布时间】:2015-07-28 22:14:51
【问题描述】:

目前我的正常保存看起来像这样(正在保存 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)
{

我可以更改后端功能,但我觉得好像缺少一些简单的角度选项

【问题讨论】:

    标签: javascript asp.net angularjs angular-resource


    【解决方案1】:

    你可以这样做:

    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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-21
      • 1970-01-01
      • 1970-01-01
      • 2017-02-27
      • 2013-01-15
      • 2010-09-19
      • 2014-05-02
      • 1970-01-01
      相关资源
      最近更新 更多