note.js 673 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. There are 5 types of services:
  3. * Most popular:
  4. * Factory: used to share functions and objects across an app.
  5. * Provider: like factory, but with configuration
  6. * Others:
  7. * Constant
  8. * Service
  9. * Value
  10. */
  11. angular.module("noteWrangler")
  12. // Naming the function <service>Factory is a common convention.
  13. .factory('Note', ['$http', function NoteFactory($http) {
  14. return {
  15. all: function () {
  16. return $http({
  17. method: "GET",
  18. url: "/notes.json",
  19. });
  20. },
  21. create: function (note) {
  22. return $http({
  23. method: "PUT",
  24. url: "/notes",
  25. data: note,
  26. });
  27. },
  28. }
  29. }]);