12345678910111213141516171819202122232425262728293031323334 |
- /*
- 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 <service>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,
- });
- },
- }
- }]);
|