AddItemPageController.js 755 B

1234567891011121314151617181920212223242526272829303132333435
  1. app.controller('AddItemPageController',['$scope',function($scope){
  2. $scope.resObj = {
  3. mealName: '',
  4. type: '',
  5. weight: '',
  6. ingredients: [,,,],
  7. imageUrl: '',
  8. price: '',
  9. isSelected: false
  10. };
  11. $scope.resObj2 = {};
  12. $scope.isFirstTab = true;
  13. var databaseMeals = firebase.database().ref().child('meals');
  14. var databaseDiets = firebase.database().ref().child('diets');
  15. //functions
  16. $scope.deleteIngredient = function(i){
  17. $scope.resObj.ingredients.splice(i,1);
  18. }
  19. $scope.addIngredient = function(){
  20. $scope.resObj.ingredients.push('');
  21. }
  22. $scope.sendMeal = function(){
  23. databaseMeals.push().set($scope.resObj);
  24. }
  25. $scope.sendDiet = function(){
  26. databaseDiets.push().set($scope.resObj2);
  27. }
  28. }])