Save data to Firebase

Hi

This is my first topic on the forum :slight_smile: hope someone can point me in the right direction.

I followed the "Custom Code Support / todo " tutorial where he explained how to add content to firebase. I want to extend that tutorial to save multiple values to firebase.

the code look like this:

angular.module('provestore', ['firebase'])


.service('Provestore', ["$firebaseArray", function($firebaseArray){
    
    var ref = firebase.database().ref().child("provedata");
    var items = $firebaseArray(ref);
    
    var prove = {
        items : items,
        addItem: function(title, calocation){
            items.$add({
                title      : title,
                //calocation : calocation //this does not work
                //calocation : 'calocation' //this work but then value is set
            })
        },
    }
    
    return prove;


}]);

and this, i tried to do the same with the second field but data does not save. i dont get errors in console.

// The following is the constructor function for this page's controller. See https://docs.angularjs.org/guide/controller
// You can include any angular dependencies as parameters for this function
// TIP: Access Route Parameters for your page via $stateParams.parameterName
function ($scope, $stateParams, Provestore) {

    $scope.data = {
        'title'         : '',
      //  'calocation'    : ''
    }
    $scope.addItem = function() {
        Provestore.addItem($scope.data.title);
        //Provestore.addItem($scope.data.calocation);
        
    }

}

Can someone please point help me or point me in the right direction/tutorial?

Thank you

I got it working :slight_smile:

Problem was with this

$scope.addItem = function() {
        Provestore.addItem($scope.data.title);
        //Provestore.addItem($scope.data.calocation);
        
    }