Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h3>Option 1: $http service</h3> <p>AngularJS provides the <a href="http://docs.angularjs.org/api/ng.$http" rel="noreferrer"><code>$http</code> service</a> that does exactly what you want: Sending AJAX requests to web services and receiving data from them, using JSON (which is perfectly for talking to REST services).</p> <p>To give an example (taken from the AngularJS documentation and slightly adapted):</p> <pre><code>$http({ method: 'GET', url: '/foo' }). success(function (data, status, headers, config) { // ... }). error(function (data, status, headers, config) { // ... }); </code></pre> <h3>Option 2: $resource service</h3> <p>Please note that there is also another service in AngularJS, the <a href="http://docs.angularjs.org/api/ngResource.$resource" rel="noreferrer"><code>$resource</code> service</a> which provides access to REST services in a more high-level fashion (example again taken from AngularJS documentation):</p> <pre><code>var Users = $resource('/user/:userId', { userId: '@id' }); var user = Users.get({ userId: 123 }, function () { user.abc = true; user.$save(); }); </code></pre> <h3>Option 3: Restangular</h3> <p>Moreover, there are also third-party solutions, such as <a href="https://github.com/mgonto/restangular" rel="noreferrer">Restangular</a>. See its <a href="https://github.com/mgonto/restangular#lets-code" rel="noreferrer">documentation</a> on how to use it. Basically, it's way more declarative and abstracts more of the details away from you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload