Angularjs api

AngularJS provides a set of services and directives for interacting with APIs. Here are the main AngularJS API services and directives:

  1. $http: The $http service is used to make HTTP requests to an API endpoint. It provides methods like get, post, put, and delete for making HTTP requests.
$http.get('/api/data').then(function(response) {
  // handle success
}, function(error) {
  // handle error
});
Source:‮igi.www‬ftidea.com
  1. $resource: The $resource service is a higher-level abstraction of $http that simplifies API interactions by providing a RESTful API client for AngularJS.
var User = $resource('/api/users/:userId', { userId: '@id' });

// get a single user
User.get({ userId: 123 }, function(user) {
  // handle success
}, function(error) {
  // handle error
});

// create a new user
User.save({ name: 'John', email: '[email protected]' }, function(user) {
  // handle success
}, function(error) {
  // handle error
});

// update an existing user
User.update({ userId: 123 }, { name: 'John Doe' }, function(user) {
  // handle success
}, function(error) {
  // handle error
});

// delete a user
User.delete({ userId: 123 }, function(user) {
  // handle success
}, function(error) {
  // handle error
});
  1. $routeParams: The $routeParams service provides access to the parameters in the current route.
app.config(function($routeProvider) {
  $routeProvider.when('/users/:userId', {
    templateUrl: 'user.html',
    controller: 'UserController'
  });
});

app.controller('UserController', function($scope, $routeParams) {
  var userId = $routeParams.userId;
});
  1. $location: The $location service is used to manipulate the URL in the browser address bar.
app.controller('MyController', function($scope, $location) {
  $scope.goToPage = function(path) {
    $location.path(path);
  };
});

These are some of the main AngularJS API services and directives that can be used to interact with APIs. Other services and directives like $q, $cacheFactory, and $timeout can also be used to implement more advanced functionality in AngularJS applications.