services.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. angular.module('starter.services', [])
  2. .factory('Chats', function() {
  3. // Might use a resource here that returns a JSON array
  4. // Some fake testing data
  5. var chats = [{
  6. id: 0,
  7. name: 'Ben Sparrow',
  8. lastText: 'You on your way?',
  9. face: 'img/ben.png'
  10. }, {
  11. id: 1,
  12. name: 'Max Lynx',
  13. lastText: 'Hey, it\'s me',
  14. face: 'img/max.png'
  15. }, {
  16. id: 2,
  17. name: 'Adam Bradleyson',
  18. lastText: 'I should buy a boat',
  19. face: 'img/adam.jpg'
  20. }, {
  21. id: 3,
  22. name: 'Perry Governor',
  23. lastText: 'Look at my mukluks!',
  24. face: 'img/perry.png'
  25. }, {
  26. id: 4,
  27. name: 'Mike Harrington',
  28. lastText: 'This is wicked good ice cream.',
  29. face: 'img/mike.png'
  30. }];
  31. return {
  32. all: function() {
  33. return chats;
  34. },
  35. remove: function(chat) {
  36. chats.splice(chats.indexOf(chat), 1);
  37. },
  38. get: function(chatId) {
  39. for (var i = 0; i < chats.length; i++) {
  40. if (chats[i].id === parseInt(chatId)) {
  41. return chats[i];
  42. }
  43. }
  44. return null;
  45. }
  46. };
  47. })
  48. .factory('Task', function ($resource) {
  49. var task = {};
  50. task.detail = {};
  51. task.getTask = $resource('http://192.168.1.6:8000/task/:id/');
  52. return task;
  53. })
  54. ;