SelectMenuPageController.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. app.controller('SelectMenuPageController',['$scope','$firebaseObject','$timeout',function($scope,$firebaseObject,$timeout){
  2. var ref = firebase.database().ref().child('meals');
  3. // var fireObj = $firebaseObject(ref);keys[i]
  4. // var mealItems = fireObj.first;
  5. // fireObj.$loaded().then(function(result){
  6. // console.log(result.first);
  7. // })
  8. $scope.mealType = 'breakfast';
  9. $scope.meals = [];
  10. $scope.selectMeal = function(i){
  11. var keys = Object.keys($scope.meals);
  12. $scope.meals[keys[i]].isSelected = true;
  13. ref.child(keys[i]).set($scope.meals[keys[i]]);
  14. }
  15. ref.on('value', snap => {
  16. // var databaseT0ests = [];
  17. // var retrievedObject = snap.val();
  18. // if(retrievedObject){
  19. // var keys = Object.keys(retrievedObject);
  20. // for (var i = 0; i < keys.length; i++) {
  21. // databaseTests[i] = retrievedObject[keys[i]];
  22. // }
  23. // }
  24. $timeout(function(){
  25. $scope.meals = snap.val();
  26. })
  27. })
  28. $scope.openSelectedMeals = function(){
  29. var selectedMeals = angular.element(document.querySelector('.selected-meals'));
  30. var appRoot = angular.element(document.querySelector('.app-root'));
  31. var overlay2 = angular.element(document.querySelector('.overlay2'));
  32. // selectedMeals.css({'transform': 'translateX(0)'})
  33. appRoot.css({'transform': 'translateX(-281px)'});
  34. overlay2.css({'pointer-events': 'auto','opacity':'1'});
  35. overlay2.on('click',function(){
  36. overlay2.css({'pointer-events': 'none','opacity':'0'});
  37. appRoot.css({'transform': 'translateX(0px)'});
  38. })
  39. }
  40. }])