In Angular, the exclusion of a name attribute in a textarea element does not automatically generate an instance

I came across this jade template for creating a modal dialog in Angular Material. Unfortunately, I couldn't convert it to HTML because the jade site was not working.

md-dialog(aria-label='Reject', ng-cloak='')
  form(name="rejectionForm")
    md-dialog-content
      .md-dialog-content
        h2.md-title Reject confirmation for
        div(ng-bind-html="vm.parent.task.label")
        div {{rejectionForm | json}}
        textarea(placeholder="Please provide a reason for rejection", name="reason", style="width: 530px; height: 75px", ng-required="true")
        div(ng-messages="rejectionForm.reason.$error")
          div(ng-message="required") You need to give the reason
    md-dialog-actions(layout="row")
      span(flex)
      md-button(ng-click="vm.parent.cancel()") CANCEL
      md-button.md-primary.md-raised(ng-click="vm.parent.reject()", ng-disabled="rejectionForm.$invalid") REJECT

The issue is that when the form field instance called reason is supposed to be created in rejectionForm, the resulting JSON does not reflect this:

{
   "$error": {},
   "$name": "rejectionForm",
   "$dirty": false,
   "$pristine": true,
   "$valid": true,
   "$invalid": false,
   "$submitted": false

This raises concerns about why the reason field is missing and why the form is not being validated as expected.

Answer №1

Without adding ng-model to the input element with a name attribute in the form, the name property will not be included in the rejectionForm form object.

To populate the reason field inside the rejectionForm form, you need to add ng-model="something".

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

Integrate a feature in React-native MapView that dynamically swaps out markers with different images

Thanks to the insights shared in this informative article, I successfully integrated observations into my MapView. mapMarkers = () => { return this.state.items.map((item) => <Marker key={item.id} coordinate={{ latitude: item.g ...

How can I retrieve data from local storage based on a specific key value using a query?

In order to optimize the storage of data for my app, I have successfully stored a large amount in local storage. Now, I am faced with the task of fetching data in an array but only selecting key/values that are specifically chosen, rather than all or jus ...

Discover the path with the power of JavaScript

Imagine I am including a JavaScript file in this manner: <script type="text/javascript" src="http://foo.com/script.js?id=120#foo"></script> Would it be possible to access the GET or hash parameters passed through this? Currently, I achieve t ...

Interactions with the mouse while using the window.alert and window.confirm features

Currently, I have developed a custom drag method that utilizes mousedown, mouseup, and mousemove events. This method is defined as move(). $(document).on('mousedown', function() {drag = true }); $(document).on('mouseup', function() {dr ...

The server is unable to process your request to /graphql

I've encountered an issue while setting up the GraphiQL API. I keep receiving the error message "Cannot POST /graphql" on both the screen and network tab of the console. Despite having similar boilerplate code functioning in another project, I'm ...

What is the best way to display an SVG file in a React application?

I am trying to figure out how to upload an SVG file and display a preview in a React component. I attempted to convert the SVG file into a React component by using the DOMParser to parse the SVG-XML string into a Document Object, but it is not functionin ...

JavaScript for Loading and Moving Ads in IE8

On my website at , I have placed my AdSense ads at the top of the page. However, I encountered an issue with Internet Explorer 8 where the Javascript code I used to move the ads to a different position on the page doesn't seem to work: <!-- POSI ...

Why does the (form.$error && form.$submitted) condition evaluate to true at the beginning?

Check out this video showcasing the bug: http://youtu.be/siOfUluPraA. Below, you'll find the code I'm working with. The issue seems to be that ng-show switches to true for just a split second. Similarly, signinForm.$submitted also becomes true ...

Establishing a global variable in Cypress through a function

My current workflow involves the following steps: 1) Extracting a field value from one page: var myID; cy.get('#MYID'). then(($txt) => { myID= $txt.text(); }) .should('not.equal', null); 2) Mo ...

Encountering an issue with the message "SyntaxError: Unexpected token < in django-jquery-file

I am currently working on implementing django-jquery-fileupload into my project. https://github.com/sigurdga/django-jquery-file-upload However, I encounter an "Error SyntaxError: Unexpected token < " when attempting to click the "start" upload button. ...

Limit the Jquery selection specifically to elements on the modal page

Recently I encountered an issue with a webpage that opens a modal form. The problem arises when the validation function, written in JQuery, checks all fields on both the modal and the page beneath it. //validate function function validateFields() { v ...

Calculating the width of fluctuating DOM elements in AngularJS

It seems like most of my Angular questions are just me overlooking something really silly, so let's hope that's the case here too. Currently, I am working on a directive to manage the scrolling of a wide list of thumbnails. While it was working ...

Do the items appear on screen only once you start typing in AngularJS?

Most things are working well except for a couple of issues Code var app = angular.module("MyApp", []); app.filter('offset', function() { return function(input, start) { start = parseInt(start, 10); return input.slice(start); }; } ...

Initializing select element with ng-init

This is the code snippet I have implemented for ng-init: <select ng-model="yourSelect3" class="form-control" ng-init="yourSelect3=requirements.Item2[0]" ng-options="yourSelect3.StateName for yourSelect3 in requirements.Item2"> &l ...

Tips for utilizing the "this" keyword in JavaScript in conjunction with the change function

I'm currently facing an issue with the change function. I have two dropdowns that are dependent on each other. Whenever the first dropdown changes, it triggers a change in the second dropdown as well. I achieved this functionality using jQuery AJAX. H ...

Conceal a secret input element's value upon clicking a submit button (using PHP and jQuery)

Greetings, I'm facing an issue and need your assistance: Here's the scenario - I have a form that gathers First Name, Last Name, and City from the user. Upon clicking submit, the provided information is then showcased within a table as follows: ...

Utilizing JavaScript to retrieve data from a self-submitting form

From my database, I am able to create a list of options for users to choose from. Once a selection is made, the values are submitted back to the same page and retrieved using Javascript. Within the same form, there are radio buttons and a multiple selecti ...

Utilizing the Chinese Remainder Theorem within JavaScript Programming

Attempting to tackle the challenge presented in part 2 of Advent of Code 2020 day 13, I came across discussions referencing the intriguing concept known as the Chinese Remainder Theorem. Various approaches were explored, including utilizing an older implem ...

Unable to associate ngModel because it is not recognized as a valid property of the "Component"

Currently, I am in the process of creating a custom form component using Angular 4. I have included all necessary components for ngModel to function properly, but unfortunately, it is not working as expected. Below is an example of my child component: ex ...

Preparing the format/serialization of a JQuery JSON array prior to submitting it

Looking at the JSON structure I have: { "firstArrayOfJSON": [ { "something" : "something" }, { "another" : "another" }, { "secondArrayOfJson" : [ ...