/* There are 5 types of services: * Factory: most common. Used to share functions and objects across an app. * Value: often used, just share a value * Provider: common. Like factory, but with configuration * Constant: rarely used, to share a value within app configuration. * Service: rarely used, a ServiceService recipe (?) to share instances of methods and objects. */ 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", }); }, find: function (id) { return $http({ method: "GET", url: "/notes/" + id.toString(), }); }, create: function (noteObj) { return $http({ method: "POST", url: "/notes", data: noteObj, }); }, update: function (nodeObj) { return $http({ method: "PUT", url: "/notes", data: nodeObj, }) }, } }]);