0

What is the difference between $location.path() and $http.get() in AngularJS ? Both seem to be working the same way in my application (I'm using the calls in a function of my application's controller to respond to a form submission) , but I feel like I'm missing something.

Any help would appreciated. Thanks.

1
  • rough answer - window.location = YOUR_URL VS. var req = new XMLHttpRequest(); req.open("GET", YOUR_URL, true); req.send(); Redirect Vs. Asynchronous Request For Data Commented May 29, 2015 at 14:18

1 Answer 1

2

$http.get() is generally used for an API call, typically you will retrieve some data with this function.

The $http service also has functions for POST, PUT, DELETE, etc... most HTTP verbs are included to call an external API.

$location.path() is mainly used for changing the url of your application, the $location service can only issue GET requests and is generally for reading/changing the url of your own, internal application

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.