app.controller('AddItemPageController',['$scope',function($scope){ $scope.resObj = { mealName: '', type: '', weight: '', ingredients: [,,,], imageUrl: '', price: '', isSelected: false } var databaseMeals = firebase.database().ref().child('meals'); //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); } }])