this is the $resource configuration.
'use strict';
angular.module('MyApp')
.factory('Doc',['$resource',function DocFactory($resource){
return $resource('/db/doc/:dbName/:docId/:docRev',
null,
{'upDate': { method:'PUT' }}
);
}]);
DELETE and GET work fine
the upDate function is called with a submit button
$scope.upDate = function(){
Doc.upDate({dbName: 'lol-sched-teams',
docId: $scope.team._id,
docRev: $scope.team._rev})
.$promise.then(function (data) {
$scope.team = data;
});
}
When I debug into angular I find that the '/db/doc/' portion of the url is working fine but the ':docId/:docRev' are not being parsed to build out the entire url.
So at the Express server the request comes in as 'req: PUT /db/doc'
?????
Obviously I am missing SOMETHING!
Any help appreciated
Problem Solved???? Well understood anyway.
This is really not well documented. Happily the angular code is beautifully written and easy to follow.
$resource REALLY WANTS 4 arguments params, data, function success(){}, function error(){}
If you debug into angular you will see this is the case on the parse of the command args So I made the PUT work by re-coding the call to the resource factory to be:
Doc.upDate({dbName: 'lol-sched-teams',
docId: $scope.team._id,
docRev: $scope.team._rev},
$scope.team,
function success(data){
console.log(data);
},
function error(err){
console.log(err);
}
)
Within angular-resource this will now parse as a1=params, a2=data, a3=success, // is A Function a4=error // is A Function
This will be all gibberish unless you use the debugger and look at it running but when you do it will be perfectly obscure