Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. angular
  2. .module('taskManager')
  3. .controller('DragListController', DragListController);
  4.  
  5. DragListController.$inject = ['$scope', '$element', 'dragularService'];
  6. function DragListController($scope, $element, dragularService){
  7.  
  8. var vm = this;
  9. vm.items = {};
  10.  
  11. vm.todoList = [];
  12. vm.inProgList = [];
  13. vm.completedList = [];
  14.  
  15. $scope.items = [];
  16.  
  17. vm.init = function($element) {
  18.  
  19. var database = firebase.database();
  20. database.ref('/task').once('value').then(function(snapshot) {
  21.  
  22. $scope.$apply(function(){
  23.  
  24. vm.items = snapshot.val();
  25. //Manipulating data from Firebase
  26. angular.forEach(vm.items, function(value) {
  27. angular.forEach(value, function(data){
  28. if(data == 'completed'){
  29. vm.completedList.push(value);
  30. }
  31. if(data == 'to-do'){
  32.  
  33. vm.todoList.push(value);
  34. }
  35. if(data == 'on the process'){
  36. vm.inProgList.push(value);
  37. }
  38. });
  39. });
  40.  
  41. dragularService($element.children().eq(0).children(), {containersModel: vm.todoList});
  42.  
  43.  
  44. });
  45.  
  46. });
  47.  
  48.  
  49. }/*End of init function*/
  50.  
  51.  
  52. vm.init($element);
  53.  
  54. }
  55.  
  56. angular.module('taskManager', [
  57. 'dragularModule',
  58. 'ngRoute',
  59. 'googlechart'
  60. ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement