2

I'm using AngularJS to integrate with a REST service which has already been built.

The REST API uses the following form for queries:

http://the.site/person/search/smith%20male (this searches for people called smith who are male)

I'm aware that this form isn't the best and will be ultimately getting the API changed to use a URL parameter.

Currently I'm just defining a resource inside my controller:

$scope.Summary = $resource("http://the.site/person/search");
this.Summary.query({ terms : 'smith male' });

but that generates URL's of the form /person/Search?terms=smith%20male

Is there a way to modify or override the URL used? I'm more familiar with Backbone where I was able to provide a url() function in my which generated the correct form of URL.

1
  • 1
    I'm not sure I would put my resource constructor function in a $scope.property like that. That's not really what that's for. A view has no reason to access a resource constructor. Commented Jan 17, 2013 at 16:49

1 Answer 1

5
$scope.Summary = $resource("http://the.site/person/search/:terms");
this.Summary.query({ terms : 'smith male' });
Sign up to request clarification or add additional context in comments.

Comments

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.