Question

app.factory('Greeter', ['$resource',function($resource){
  return $resource(
    'http://123.com/processor.php?'+'myvar=1066',
    {callback: 'JSON_CALLBACK'},
    {
      query: {method:'GET',isArray:true}
    });
}]);

I tried to pass a simple static variable into a php file to get call back value yet, its seem not pass correctly with the way I use above. Since the chrome inspector shows that

Query String Parametersview parsed
callback=JSON_CALLBACK

I wonder what is the right way to do it?

Thank You

Was it helpful?

Solution

Try this

app.factory('Greeter', ['$resource',function($resource){
  return $resource(
    'http://123.com/processor.php',
    {

          myvar: 1066,
          callback: 'JSON_CALLBACK'
    },
    {
      query: {method:'GET',isArray:true}
    });
}]);

Now you should get

http://123.com/processor.php?myvar=1066&callback=JSON_CALLBACK

after doing the following

Greeter.query()

or

http://123.com/processor.php?myvar=1066&callback=JSON_CALLBACK&myvar2=77777

by doing this

Greeter.query({myvar2: 77777});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top