angular services - Angularjs: Pass parameter from controller to factory -


i have following code in service

define(['./module'], function(services) { 'use strict'; services.factory('user_resources', ['$resource', '$location', function($resource, $location) {        return $resource("", {},                 {                     'testservice':{method:"get",url:'http://11.11.11.11/url/index.php?data={method:method_name,params:{param1:value,param2:value,}}',isarray:true}                 });  }]); }); 

from controller calling factory method how pass parameters testservice controller?

following code in controller call factory

user_resources.testservice().$promise.then(function(data) {   console.log("****************************");           console.log(data);   $scope.mylist=data;      }); 

thats not how $resource works.

$resource("http://11.11.11.11/url/index.php",              {'testservice':{method:"get",url:'http://11.11.11.11/url/index.php',isarray:true}}) 

then call with:

var theobjtosend = {                     method:method_name,                     params:                          {                             param1:value,                             param2:value                          }                    }; new user_resources({data: theobjtosend}).testservice(); 

or

user_resources.testservice({data: theobjtosend}); 

its going serialize object might weird. reason why dont use query parameters?
e.g.

?method=method_name&params={param1:value,param2:value} 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -