Tuesday, 29 August 2017

angular $resource

find is not a default action for $resource. The defaults are:
{ 'get':    {method:'GET'},
  'save':   {method:'POST'},
  'query':  {method:'GET', isArray:true},
  'remove': {method:'DELETE'},
  'delete': {method:'DELETE'} };
You will have to create/specify the find action. You are currently creating/specifying a chargeaction. Perhaps this is what you meant to use?
If you want to use find, here is the fix:
.factory('testResource1', function ($resource) {
     return $resource('/SoloAngularTable/TestMethod3', { id: '@id' }, {
         charge: { method: 'POST' },
         find: { method: 'POST' } // Added `find` action
     });
});
If you meant to use charge, here is the fix:
.controller('ContentPlaceHolder1Controller', function ($scope, $http, testResource1) {                            
     testResource1.charge({ id: 123 }, function (data) {                            
          alert('success');
     });
});

No comments:

Post a Comment