Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
AngularJS

Factories in AngularJS

Create services with .factory() returning an object or function.

Factories in AngularJS — a practical guide to AngularJS factory with clear examples you can reuse in real projects.

AngularJS Tutorial Series (46/99). Prefer one article? Read the complete AngularJS tutorial.

Short description

Factories are often preferred for revealing-module style APIs.

factory()

angular.module('myApp').factory('ItemApi', ['$http', function ($http) {
  return {
    list: function () { return $http.get('/api/items'); }
  };
}]);

Leave a reply

Your email address will not be published. Required fields are marked *