3
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

1

1 Answer 1

2

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});
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks! Worked well : D
Would you mind to show me how to reference the input in this case? Because the input field attribute as 'name' seem can not be reference correctly. I always got undefined value when I do that. Thanks!
Assuming you are trying to use this field to pass to the query. You have to use <input ng-model="criteria.name" type="text"> and assuming you have a controller up there somewhere. You can do Greeter.query({ name: $scope.criteria.name}). If my assumptions are not correct I suggest you open a new question and perhaps post some plnkr/jsfiddle for quick working solution/answer.
I did almost just that, but seem not really work the way it should be.. here is a new post about it, please feel free check it out :) appreciated! stackoverflow.com/questions/25083305/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.