unable to retrieve the ng-model's value

Why is the value of emailia returning undefined? I'm getting the correct value at "nachricht." I used the same method for emailia. Check out the function $scope.nachrichtSenden = function(anzeige).

angular.module('app', []).controller("MainController", function($scope, $http) {
    $scope.anzeigen = [];
    $scope.anzeigenGefiltert = [];
    $scope.man = true;
    $scope.woman = true;
    $scope.liebe = 'Test';
    $scope.liebeId = -2;
    $scope.email;

    $scope.getAnzeigen = function() {
        $http.get('getAnzeigen').success(function(data) {
            $scope.anzeigen = data;

            for (var i = 0; i < data.length; i++) {
                $scope.anzeigen[i].geburtsdatum = moment($scope.anzeigen[i].geburtsdatum.date).locale("de").format('LL');
            }

            console.log($scope.anzeigen);
        });
    };

    $scope.nachrichtSenden = function(anzeige) {
        $http.get(
            'nachrichtSenden?id=' +
            anzeige.id +
            "&nachricht=" +
            $scope.nachricht +
            "&email=" +
            $scope.emailia
        ).success(function(data) {
            console.log($scope.tada);
        });
    };

    $scope.getAnzeigen();
});
        <div ng-show="$parent.liebe == anzeige.id">
            <h3>Your message to {{'{{anzeige.spitzname}}'}}</h3>
            <textarea name="nachricht" class="form-control" rows="5" id="comment" ng-model="$parent.nachricht"></textarea>
            <input type="text" ng-model="emailia">
            <button type="button" style="float: right;" ng-click="nachrichtSenden(anzeige)" class="btn btn-warning btn-md">
                Send!
            </button>

        </div>

Answer №1

A variable called $scope.email has been declared in your code.

However, there is an attempt to access a variable named $scope.emailia, which is not defined and therefore returns undefined.

Answer №2

It seems like there is a typo in your code where you have written console.log($scope.tada). Make sure to double-check it.

 $scope.sendMessage = function(display){
    $http.get(
      'sendMessage?id=' +
      display.id +
      "&message=" +
      $scope.message +
      "&email=" +
      $scope.emailia 
     ).success(function(data){
          console.log($scope.tada);

     });
  };

Take a closer look at your code. You have written console.log($scope.tada);, but it should be console.log($scope.data);.

Maybe correcting this mistake will solve the issue.

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

Issue: ArrayBuffer failing to function properly in conjunction with Float64Array in NodeJS

Having some trouble with getting a Float64Array to work with an array buffer in Node. Here's what I've tried... var ab = new ArrayBuffer(buffer.length); var view = new Uint8Array(ab); console.log(view.length);//prints 3204 However, when I try ...

A JSON request is being processed within a while loop

Attempting to complete what I initially thought was a simple task has led me to believe that I may have oversimplified the process or made a mistake in my loop. My objective is to browse through a series of links containing JSON objects in order to identif ...

Vuetify - Implementing a search feature in a table that automatically navigates to the matching row

Currently, I am working with 2 Vuetify data tables that do not have pagination enabled. Each row in the second table corresponds to exactly one parent in the first table. My goal is to be able to click on an entry in the second table and have it automati ...

Storing and Editing Collection of Elements

My latest project involves creating a basic web scraping tool that gathers information on apartment prices from a specific webpage. Each time the tool runs, it compiles an array of objects with details such as date, time, floor plan name, bed number, floor ...

What steps can I take to resolve the issue with the cdk module?

click here for image This persistent error keeps appearing whenever I try to resize the window. I was hoping that when I decrease the page size, the search bar would transform into an icon with a dropdown search function. Despite my attempts to modify the ...

Checkbox selection problem caused by repeated clicking

What I accomplished 1. Generated an array of checkboxes with unique numeric ID 2. Utilized jQuery to toggle checkbox status on click of <td>(also with unique numeric ID) 3. Implemented check-uncheck logic using jQuery. Issue : Initially, ...

What is the best way to upload this file in VueJS?

I've come across a file written in outdated syntax that I need to use in a VueJS Component. You can find the file here. For instance, consider these snippets from the file: var CCC = CCC || {}; CCC.STATIC = CCC.STATIC || {}; CCC.STATIC.TYPE = { & ...

Mastering the correct way to access array index positions in Vuejs

HelloWorld.vue <template> <div> <div v-for="(pizza, index) in pizzas" :key="pizza.name"> {{ pizza.name }} <List :content="matchingPizza" :pname="pizza.name" :qname="quantities[index] ? ...

Prevent the execution of a Javascript function if it is already in progress

I've developed a function that retrieves records from a third party, and this function runs every 10 seconds. However, as I debug through Firefox, I notice a long queue of ajax requests. I'm contemplating including a statement that can signal to ...

Execute functions upon the completion of jQuery ajax requests

I need to trigger my function loadTest() once the bootstrap dialog is fully loaded and displayed. $(".btn").on("click", function() { $.ajax({ type: "POST", url: '/echo/html/', data: { html: '', ...

md-list-item containing md-radio-button

Trying to tackle this particular issue: https://github.com/angular/material2/issues/1518 I want the ability to click anywhere on the line of my md-item and have it trigger the radio-button action. settings.component.html : <md-radio-group [(ngModel) ...

Load the PHP elements once the nav tab has been switched

I have a project with 10 tabs, each of them fetches data from an API using PHP. The loading time for the page is around 10-15 seconds since it updates all values for the 10 tabs. Is there a way to load content only when switching between tabs? Start by l ...

What caused the D3 link labels to suddenly cease functioning?

I've come across an issue with my code that previously displayed link names from json data on node links. // Append text to Link lines var linkText = vis.selectAll(".gLink") .data(json.links) .append("text") .attr("class", "link") .attr("x", function ...

mdDatepicker malfunctions in combination with AngularJS versions 1.5.9 and 1.6

Angular 1.5.9 brought about some interesting performance improvements: $compileProvider.commentDirectivesEnabled( false ); // turned off comment directives $compileProvider.cssClassDirectivesEnabled( false ); // disabled css class directives In updating ...

Make sure to verify if all values are contained within an array by utilizing JavaScript or TypeScript

These are the two arrays I'm working with. My goal is to ensure that every value in ValuesToBeCheckArr is present in ActualArr. If any values are missing from ActualArr, the function should return 0 or false. Additionally, there is an operator variabl ...

What is the best way to ensure that a component remains the highest layer on a react-leaflet map?

I am encountering an issue where the table on my page only shows for a brief second when I refresh the page, and then it disappears. The Map Component being used is a react-leaflet map. I would like to have a component always displayed on top of the map wi ...

The $timeout function in AngularJS seems to be malfunctioning

I'm attempting to add a delayed effect to my view. After a button is clicked, a message is displayed, but I want it to disappear after 2000ms. I have tried implementing a $timeout function based on recommendations I found, but it doesn't seem to ...

Is there a way to simulate a service that is automatically called as soon as the controller is loaded?

Upon loading, my controller immediately fetches data from a service. angular.module('app').controller("MyController", function (myService) { var projectId = myservice.project.id; }); The data is set from a previous action within the applica ...

The converted document exported using threejs-usdzExporter does not appear correctly on an iPhone

I loaded a glb file using THREE.js GLTFLoader and then exported it to usdz using USDZ Exporter. When I tried to open it in the browser, it showed up in Safari but didn't appear in ARkit in object mode. Instead, it appeared above my head in AR mode. Th ...

Storing input field values in JavaScript using the onchange event handler.Would you like a different revision

I am looking to calculate the area by multiplying width and height entered into input fields, and then display the result. Any guidance would be greatly appreciated. Thank you! Here is my current code. const width = document.querySelector("#width"); con ...