Restangular call service as query string parameters angularjs

How to call a service as query string(like shown below) parameters in angularjs??

/resource/subelement?query=param

Get to know what is restangular here

application-service.js:

var getDetails = function(application, location, product) {
return $q(function(resolve, reject){
var params = {
product: product,
location: location,
};

Restangular.one(‘servicename’).customPOST(application, “”, params, {}).then(function(response){
console.log(“servicename”, response);

resolve(response);
}, function(reason){
reject(‘Problem submitting the application. Reason: ‘ + reason);
});
});
};

Now in controller where ever you should call this getDetails method. Just add ApplicationService as dependency injection. Thats it, you can run your application and check response in console.log after service call.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s