himanish.k
himanish.k

Reputation: 117

$location.path() vs $http.get() - AngularJS

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.

Upvotes: 0

Views: 544

Answers (1)

Robin-Hoodie
Robin-Hoodie

Reputation: 4974

$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

Upvotes: 2

Related Questions