AngularFire and Ionic - There is no data being sent to the server from the form

I am using Ionic and AngularFire to build my app, but I have encountered a new issue: the form data is empty! Only the fields in my Firebase database are visible. How can I retrieve the user-entered form data from the Firebase database?

Here is a screenshot of the issue:

This is the HTML code snippet:

<form ng-submit="submitEvent(event)">
  <label class="item item-input item-stacked-label">
    <span class="input-label"><i class="fa fa-pencil"></i> Event Name</span>
    <input type="text" ng-model="event.nameid">
  </label>
  <label class="item item-input item-stacked-label">
    <span class="input-label"><i class="icon ion-ios-information"></i> Description</span>
    <br><textarea ng-model="event.descriptionid"></textarea>
  </label>
  <label class="item item-input item-stacked-label">
    <span class="input-label"><i class="fa fa-location-arrow"></i> Address</span>
    <input type="text" ng-model="event.addressid">
  </label>

  <button class="button" type="submit" value="Add Event" id="success-btn-create"><i class="fa fa-arrow-right"></i></button></form> 

This is the Controller JS code snippet:

myApp.controller('Step1Ctrl', ['$scope', 'Event', 'Auth', '$rootScope', '$state', '$firebaseArray', function($scope, Event, Auth, $rootScope, $state, $firebaseArray) {

  $scope.submitEvent = function(event) {

    var nameid = $scope.nameid;
    var eventRef = new Firebase("https://myApp.firebaseio.com/Events");
    eventRef.push($scope.event);
    $scope.event = {nameid: '', descriptionid: '', adressid: ''};

  }

  $scope.deleteEvent = function(index) {
    $scope.events.splice(index , 1);
  }


}])

This is the Service JS code snippet:

myApp.factory("Event", ["$firebaseArray", function($firebaseArray) {
var eventRef = new Firebase('https://myApp.firebaseio.com/Events/');
  return $firebaseArray(eventRef);
}]);

One additional question: how do I retrieve the name of the organizer who is logged in with Facebook?

Thank you all!

Answer №1

Make sure to include the following code snippet in your controller:

$scope.submitEvent = function(event) {

   Event.add(event).then(function (data){ 
      $scope.event = {nameid: null, descriptionid: null, adressid: null};
     });
  }

You may also want to consider reorganizing your service like this:

myApp.factory("Event", ["$firebaseArray", function($firebaseArray) {
  var eventRef = new Firebase('https://myApp.firebaseio.com/Events/');
  return {
         get: function (){
                return $firebaseArray(eventRef);
              }
            ,
        add: function (event){
          var eventInfo = $firebaseArray(eventRef);
          return eventInfo.$add(event);
              }
       }
}]);

I hope this information proves helpful!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Learn how to convert data to lowercase using Vue.js 2

I am attempting to convert some data to lowercase (always lowercase) I am creating a search input like : <template id="search"> <div> <input type="text" v-model="search"> <li v-show="'hello'.includes(sea ...

Is there a way to share the Username and Password without the need to manually input it?

My goal is to develop a C++ application for my classmates at school. Currently, they are required to visit our school's website and navigate to the login page. Once there, they enter their username and password, log in, and proceed to find their spec ...

Tips for Utilizing Both getElementByID and getElementByTagName Functions in JavaScript

Hi! I'm a beginner in JavaScript and I've managed to retrieve some data using getElementById. Now, I want to extract a specific part using getElementsByTagName. document.getElementById('titleUserReviewsTeaser').innerHTML; " < ...

Understanding how to parse an array of arrays in JavaScript can be a

Looking for a function that can extract a value from an array containing multiple arrays? Simply use getValueFromArray(array, [2, 4]) to get the 4th element of the 2d array within the main array. Check out the code snippet below: function getValueFromArr ...

Step-by-step guide on Setting up the bronto.sca.cart object using Bronto JSON

I have implemented the Bronto Tag Manager to track cart details successfully. After including the Bronto Commerce JavaScript snippet on my page, I am now able to create the bronto.sca object. While bronto.sca.config() and bronto.sca.id are returning valu ...

What is the method for generating three inputs simultaneously in a single line?

I'm facing a challenge in my code where I want each line to contain only three input fields. Whenever I try to add a fourth input field, the first one remains on the previous line while the other three move to the next line. Oddly enough, this issue o ...

Tips for Retrieving Html Element Attributes Using AngularJS

Update: Even though the discussion veered off track, the main question still stands - how can I access an attribute of an HTML element within an Angular controller? Check out my attempt on Plnkr: http://plnkr.co/edit/0VMeFAMEnc0XeQWJiLHm?p=preview // ...

Sending an object from ng-repeat to a different page for the purpose of showcasing its contents

Currently, I am immersed in a project that involves MySQL, Angular, Express, and Node. Within this project, I have an array of objects displayed using ng-repeat. The goal is to allow users to click on a specific item and navigate to another page where they ...

Trouble with Setting a Background Image in Ionic with Javascript and Angular

I'm having trouble getting my background image to display in this Ionic project using CSS. It works when I embed it directly into the HTML, but that's not an ideal solution. I vaguely recall something about using base64 for images, but I'm n ...

Python does not return the AJAX request back to JavaScript unless JQuery is not utilized

I have set up an XMLHTTPrequest in my javascript code to communicate with a flask location. Here's how I am doing it: var ourRequest = new XMLHttpRequest(); ourRequest.open("GET", "makeDiff") diff = ourRequest.send(); console.log(diff); Once the req ...

Can Angular send a PDF to a .NetCore server?

I have a situation where I am generating a PDF using jsPDF and then attempting to send it to the .NetCore server. I convert the PDF file to a binary string on the front-end and try to reconvert it back to PDF using C#. However, when the service calls the c ...

Control the start and stop of an Express.js app in Node.js using PHP

I'm currently developing a web service using express.js in the node.js npm environment. In order to deliver this project to my client, I need to create a controller file that allows me to start and stop the server without having to use the command pr ...

Learn how to automatically populate input fields based on the values entered in previous fields. These dynamic fields are generated based on the user

In the following code snippet, fields are dynamically created using jQuery... For more visual explanation, refer to this image: The goal is to calculate the grand total based on previous inputs and display the result when an onclick() event occurs. < ...

Getting a value from a Child component to a Parent component in Nuxt.js - a step-by-step guide

I am facing a challenge in passing data from Child A component to Parent, and then from the Parent to Child B using props. In my project using nuxt.js, I have the following structure: layouts/default.vue The default template loads multiple components wh ...

One way to submit a value form in an iframe is by double clicking

I am looking to submit a value form in a frame that functions as described below: index.php <form action="iframe1.php" method="post" target="iframe1"> <input type="text" name="lala"> <input type="submit"> </form> <iframe name= ...

Using the 'client-side rendering' and runtime environment variables in Next.js with the App Router

In the documentation for next.js, it's mentioned that runtime environment variables can be utilized on dynamically rendered pages. The test scenario being discussed involves a Next.js 14 project with an app router. On the page below, the environment ...

Preserve information across different AngularJS views using vs-google-autocomplete

Currently, I am in the process of developing my inaugural Angular Application, which enables users to sift through a database of vendors using various criteria. One such criterion is the vendor's location and the distance from the user. In order to t ...

What could be causing the lack of value appearing after I clicked the button?

Setting the value for the array of images as an empty string does not return the expected result. When I move one of the 4 images and click the button, I anticipate a new array with the information of one of the four images including src, x, and y coordina ...

ag-grid Advanced Sorting Feature for Grouped Data

Currently, I am utilizing ag-grid to implement row grouping on two different levels: Title and Date. Is there a way for me to configure the group column so that it shows the hierarchy with Titles (rowGroupIndex: 0) sorted in ascending order, while Dates ( ...

Enhancing the visual display of a webpage using AngularJS

Hello there! I'm currently working on enhancing an angular 1.6 app and have encountered a dilemma that needs solving. Let me provide some context: The page in question is a lengthy form consisting of thirty questions. The client-side logic includes nu ...