Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. angular.module('starter.services', [])
  2.  
  3. .factory('Events', function ($http) {
  4.  
  5. var events = [];
  6. return {
  7. all: function () {
  8. return $http.get("http://appserver.falconinet.com/events.lasso");
  9.  
  10. starter.services.all().then(function successCallback(response) {
  11. $scope.events = data;
  12. })
  13. }
  14. }
  15.  
  16. return {
  17. all: function () {
  18. return events;
  19. },
  20. remove: function (event) {
  21. events.splice(events.indexOf(event), 1);
  22. },
  23. get: function (eventId) {
  24. for (var i = 0; i < events.length; i++) {
  25. if (events[i].id === parseInt(eventId)) {
  26. return events[i];
  27. }
  28. }
  29. return null;
  30. }
  31. }
  32. })
  33.  
  34. // events
  35.  
  36. .controller('EventsCtrl', function ($scope, Events) {
  37. $scope.events = Events.all();
  38. console.log($scope.events);
  39. $scope.remove = function (event) {
  40. Events.remove(event);
  41. }
  42. })
  43.  
  44. .controller('EventDetailCtrl', function ($scope, $stateParams, Events) {
  45. $scope.event = Events.get($stateParams.eventId);
  46. })
  47.  
  48. return {
  49. all: function() {
  50. return $http.get("http://appserver.falconinet.com/events.lasso");
  51. },
  52.  
  53. starter.services.all().then(function successCallback(response) {
  54. $scope.variableName = data;
  55. })
  56.  
  57. var app = angular.module('plunker', []);
  58.  
  59. app.controller('MainCtrl', function($scope, Events) {
  60. Events.all().then(function successCallback(response) {
  61. $scope.events = response.data;
  62. });
  63. });
  64.  
  65. app.factory('Events', function($http) {
  66. return {
  67. all: function() {
  68. return $http.get("http://appserver.falconinet.com/events.lasso");
  69. }
  70. }
  71. });
  72.  
  73. appModule.factory('Events', function() {
  74. // Might use a resource here that returns a JSON array
  75.  
  76. // Some fake testing data
  77. var events = [{
  78. id: 0,
  79. title: 'Swing Dance Party',
  80. subtitle: 'Lets Get Dancing!',
  81. when: 'Thursday, Feb 19, 2015 (6:30-9PM)',
  82. picture: 'http://goldsea.com/Text/images/8198.jpg',
  83. desc: 'Dance, dance, dance and enjoy mixed drinks, wine, or 40 beers on tap. Krista Mccart & Steve Davis will be doing a short 30 minute class for first time beginners at 6:30 and the dance starts at 7:00. The dance and lesson are free!!!'
  84. }, {
  85. id: 1,
  86. title: 'St. Patricks Day Party',
  87. subtitle: 'with Special Guest The Menders',
  88. when: 'Saturday, March 14th (9PM)',
  89. picture: 'img/menders.png',
  90. desc: 'Based out of Gastonia, NC, The Menders have been blending influences such as the Beatles, Jack White, The Doors, and Ryan Adams into a folk-laced garage rock sound. Since 2011, they've been honing their craft around NC at venues such as Double Door Inn, The Visulite, The Milestone, Tremont Music Hall, and Snug Harbor. With an upcoming debut self-titled album, lyrics dealing with the complexities of life and death, 4 part harmonies, and energetic live performances, The Menders seek to offer their fans and listeners a music experience that is sure to leave a lasting impression.'
  91. }];
  92.  
  93. return {
  94. all: function() {
  95. return events;
  96. },
  97. remove: function(event) {
  98. events.splice(events.indexOf(event), 1);
  99. return events;
  100. },
  101. get: function(eventId) {
  102. for (var i = 0; i < events.length; i++) {
  103. if (events[i].id === parseInt(eventId)) {
  104. return events[i];
  105. }
  106. }
  107. return null;
  108. }
  109. }
  110. })
  111.  
  112. appModule.controller('EventsCtrl', ['$scope', 'Events', function($scope, Event) {
  113.  
  114. var events = Event.all();
  115. console.log('events', events);
  116. var first_event = Event.get(0);
  117. console.log('first_event', first_event);
  118. $scope.remove = function(event) {
  119. console.log(Events.remove(event));
  120. }
  121.  
  122. }]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement