0

I'm very new to AngularJS and Firebase. Currently facing some issues in taking data from a form and putting it in Firebase. I have no console logs, but the data just does'nt go into Firebase hope some kind soul can help me out :(

index.html

      <!-- Firebase -->
     <script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<script src="https://www.gstatic.com/firebasejs/3.6.5/firebase.js"></script>
<script>
  // Initialize Firebase
  var config = {
    apiKey: "x",
    authDomain: "x",
    databaseURL: "x",
    storageBucket: "x",
    messagingSenderId: "x"
  };
  firebase.initializeApp(config);

    // Get a reference to the database service
  var database = firebase.database();
</script>
<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/2.2.0/angularfire.min.js"></script>

form (sell.html)

<h1 id="sell-heading4" style="color: rgb(0, 0, 0);">Test</h1> <form ng-submit="appsell()"> <label class="item item-input" id="sell-input4"> <span class="input-label">Input</span> <input placeholder="" type="text" ng-model="name"> </label> <label class="item item-input" id="sell-input4"> <span class="input-label">Input2</span> <input placeholder="" type="text" ng-model="name2"> </label> <button id="sell-button3" class="button button-positive button-block" >Tap me!</button> </form>

controller.js

    .controller('sellCtrl', ['$scope', '$stateParams', '$firebaseArray', // 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, $firebaseArray) {

var ref = firebase.database().ref();

$scope.data = $firebaseArray(ref);

$scope.addsell = function(){
    $scope.data.$add($scope.name1);
    $scope.data.$add($scope.name2);
}

1 Answer 1

1

You may have not linked the controller into your code in index.html. (Using ng-controller directive)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.