/* There are 5 types of services: * Most popular: * Factory: used to share functions and objects across an app. * Provider: like factory, but with configuration * Others: * Constant * Service * Value */ angular.module("noteWrangler") // Naming the function Factory is a common convention. .factory('Note', ['$http', function NoteFactory($http) { return { all: function () { return $http({ method: "GET", url: "/notes.json", }); }, create: function (note) { return $http({ method: "PUT", url: "/notes", data: note, }); }, } }]);