how to make Generic method for rest call in angularjs -


how make generic method rest call in angularjs ?

i have tried single request, it's working fine

uiapproute.controller('test', ['$scope', 'checkstatus', function($scope, checkstatus) {     $scope.data = {};     checkstatus.query(function(response) {       $scope.data.resp = response;     }); }])    uiappresource.factory('checkstatus', function($resource){     return $resource(baseurl + 'status', {}, {'query': {method: 'get', isarray: false}}) }) 

i want make generic request

please share sample,.. in advance

i'm using :

.factory('factoryresource', ['$resource', 'conf',     function($resource, conf) {         return {             get: function(endpoint, method) {                 var resource = $resource(conf.baseurl + endpoint, {}, {                     get: {                         method: method || 'get'                     }                 });                  return resource.get().$promise;             }         };     } ]) 

called :

factoryresource.get(conf.testendpoint, "post"); // make post , return promise , data object factoryresource.get(conf.testendpoint, "get"); // make getand return promise , data object factoryresource.get(conf.testendpoint); // make getand return promise , data object 

with config file having :

angular.module('app.constant', [])  .constant('conf', {     baseurl: 'http://localhost:8787',     testendpoint: '/api/test' }); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -