Default $resource POST data

前端 未结 7 1236
天命终不由人
天命终不由人 2021-02-07 11:51

That might be strange but I need to specify some default POST data for my $resource using the factory method of the module.

Does anyone have an idea of how to do that in

相关标签:
7条回答
  • I think most have missed a tiny gem in the documentation here.

    non-GET "class" actions: Resource.action([parameters], postData, [success], [error])
    

    This suggests you can do the following.

    var User = $resource('/user');
    postData = { name : 'Sunil', 'surname' : 'Shantha' };
    
    var user = User.save({notify:'true'}, postData, function() {
      // success!
    });
    

    The second parameter when doing a save action (post) is post data.

    0 讨论(0)
提交回复
热议问题