AddItemPageController.js 556 B

12345678910111213141516171819202122232425262728
  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. var databaseMeals = firebase.database().ref().child('meals');
  12. //functions
  13. $scope.deleteIngredient = function(i){
  14. $scope.resObj.ingredients.splice(i,1);
  15. }
  16. $scope.addIngredient = function(){
  17. $scope.resObj.ingredients.push('');
  18. }
  19. $scope.sendMeal = function(){
  20. databaseMeals.push().set($scope.resObj);
  21. }
  22. }])