app.controller('AddItemPageController',['$scope',function($scope){ $scope.resObj = { mealName: '', type: '', weight: '', ingredients: [,,,], imageUrl: '', price: '', isSelected: false }; $scope.resObj2 = {}; $scope.isFirstTab = true; var databaseMeals = firebase.database().ref().child('meals'); var databaseDiets = firebase.database().ref().child('diets'); //functions $scope.deleteIngredient = function(i){ $scope.resObj.ingredients.splice(i,1); } $scope.addIngredient = function(){ $scope.resObj.ingredients.push(''); } $scope.sendMeal = function(){ databaseMeals.push().set($scope.resObj); } $scope.sendDiet = function(){ databaseDiets.push().set($scope.resObj2); } }])