Skip to content

Commit

Permalink
Allow $http configuration for CouchDoc.save
Browse files Browse the repository at this point in the history
This commit allows additional configuration parameters to be sent for the $http request in `CouchDoc.save`.  I need to do this in order to work around angular/angular.js#1463
  • Loading branch information
bkeil committed Jul 15, 2014
1 parent b8167e8 commit 5858bb2
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions angular-cornercouch.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,21 @@ factory('cornercouch', ['$http', function($http) {
});
};

CouchDoc.prototype.save = function() {
CouchDoc.prototype.save = function(extraConfig) {

var config;
if (this._id)
config = {
method: "PUT" ,
url: encodeUri(dbUri, this._id)
};
else
config = {
method: "POST",
url: dbUri
};
if (extraConfig) {
config = angular.copy(extraConfig);
} else {
config = {};
}
if (this._id) {
config.method = "PUT";
config.url = encodeUri(dbUri, this._id);
} else {
config.method = "POST";
config.url = dbUri;
};

var doc = config.data = this;

Expand Down

0 comments on commit 5858bb2

Please sign in to comment.