The ng-submit function in AngularJS is causing some issues and not functioning properly

In my HTML view, I have an ng-template which contains a form. I am trying to submit form data using ng-submit, but when I click on the submit button, nothing happens. However, other data bindings are working fine with text fields in the form, using ng-model in my controller. Below is the HTML code snippet:

   <script type="text/ng-template" id="updatetemplate">
   <div class="box box-primary">
   <div class="box-header with-border">
   <h3 class="box-title">Update</h3>
   </div>
   <!-- /.box-header -->
   <!-- form start -->
   <form name="update_form" ng-submit="updateUser(ngDialogData.id,  ngDialogData.currentname, ngDialogData.currentroleid)">
   <div class="box-body">
   <div class="form-group">
   <input type="hidden" name="userid" ng-model="ngDialogData.id"   class="form-control">
   <label>Name</label>
   <input type="text" class="form-control" name="name" ng-model="ngDialogData.currentname" placeholder="Enter name">
   <p></p>
   <label>User role</label>
   <input type="text" class="form-control" name="roleid" ng-model="ngDialogData.currentroleid" placeholder="Enter name">
   </select>

   </div>

   </div>
   <!-- /.box-body -->

   <div class="box-footer">
     <button type="submit" class="btn btn-primary" name="updatebutton">Update</button>
   </div>
   </form>
   </div>
   <!-- /.box -->
   </script>

Answer №1

Here are some necessary code corrections:

  • Ensure there are no blank spaces in the ng-model attribute.
  • Instead of passing each individual ng-model into the updateUser function, pass the entire ngDialogData object.
  • Remove the invalid </select> tag from the form.

Reference working fiddle: https://jsfiddle.net/d8ye0sbz/

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

The Ionic project compilation was unsuccessful

Issue: This module is defined using 'export =', and can only be utilized with a default import if the 'allowSyntheticDefaultImports' flag is enabled. Error found in the file: 1 import FormData from "form-data"; ~~~~~~~~ node ...

What is the method for retrieving the locale value from the configuration in Next.js?

How can I retrieve the i18n.defaultLocale value from my Next.js app configuration? I thought it would be simple, but I'm struggling to find a clear solution for accessing the config settings in Next.js. Is there a specific built-in method for this, or ...

Troubleshooting Problem: Incompatibility with Angular 1 and Angular 2 Hybrid Application causing Display Issue with Components

In my development work, I have created a unique hybrid application that combines Angular 1 and Angular 2 functionalities. This hybrid setup was achieved by following the guidelines provided in two helpful resources: Upgrading from AngularJS and Migrating A ...

conceal the act of pushing

After adding a property in a push function to toggle between hiding the label and showing the input, there is a need to reverse this action when the user clicks on Save changes. This can be achieved by using the ng-hide directive. <tr ng-repeat="pe ...

Issue when attempting to animate an SVG point using translateX transformation

I am attempting to create a basic animation using the translate X property on a section of my svg when hovering over the element. Here is the code I have so far: <html> <style> .big-dot:hover { transform: translateX(20px); animat ...

Counting JQuery Classes in an HTML Document

My task involves creating a dynamic HTML form that allows users to enter card values, which are then counted and styled accordingly. Each set of cards is contained within a <section> element. However, I encountered an issue with my jQuery code where ...

How to create a floating <Toolbar/> with ReactJS, Redux, and Material-UI

Can anyone help me figure out how to make a toolbar floatable when scrolling down using Material-UI? I tried setting textAlign:'center', position: 'fixed', top: 0, but it's resizing strangely when applied to the <Toolbar/>. ...

Handlers for event(s) not triggering on video element

In my NextJS application, I have implemented a feature to display a video file using the video element. I have added multiple event handlers to the video element: <video className='video-player' controls={true} preload='metadata&apo ...

Issue with passing down attribute values in polymer web components

Recently, I embarked on creating my own unique set of WebComponents library over at Github. Through testing, I found that everything functions smoothly in isolation. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...

Ways to avoid a child element from overlapping another element

(I acknowledge that the question may sound a bit off, so please feel free to edit it if you can rephrase it better). So, I have this: jsFiddle As you can see, I'm attempting to recreate a basic Windows 7 aero effect (just for curiosity, fun, and lea ...

Plugin for creating a navigation bar with a jQuery and Outlook-inspired style

Our team is considering transitioning our asp.net forms application to MVC. Currently, we utilize outlook-style navigation with ASP controls such as listview and accordion, using code referenced here. Are there any jQuery/CSS controls available for MVC t ...

How can I add navigation dots to my slider?

I've been experimenting with my slider and I managed to make it slide automatically. However, the issue is that there is no option to manually navigate through the slides. I am looking to add navigation dots at the bottom so users can easily switch be ...

What is the best way to deal with empty arrays during serialization of modified form elements only?

Managing a form with numerous multi-select fields can be challenging, especially when dealing with paged ajax. With each select having a unique ID and named accordingly as values[foobar1][], values[foobar2][], values[foobar3][], and so on, it's crucia ...

One specific JS file fails to load only when using Internet Explorer Browser in conjunction with the debugger

I am encountering an issue with a project that utilizes angular JavaScript controllers to populate fields. Unfortunately, a specific page, members.cshtml, is not loading properly in Internet Explorer 11, despite working perfectly on Chrome and Firefox. Af ...

I kindly request your assistance in resolving the issues with the append() and empty

Here is some code I've been working on: <!DOCTYPE html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function(){ ...

A guide on designing a personalized search bar for MUI-Datatables with a sleek outlined style

Check out the default UI from MUI-Datatables v4.3.0 here: https://i.stack.imgur.com/rbHgD.png I want to create a style similar to this: https://i.stack.imgur.com/AUHqC.png Just so you know, I am using the following packages: "@mui/material": &q ...

Enhance User Experience with React JS Multi-Select Dropdown Feature

I am dealing with 4 select dropdowns. The values selected should not be available in the remaining dropdown lists. Here is an overview of my state: this.state = { selectedDropdownArray: {}, dropdownArray: ['select', '1', &apos ...

Observing a sessionStorage variable within AngularJS version 1.0.7

Is there a way to monitor a sessionStorage variable in AngularJS 1.0.7 without relying on a directive? For example: $scope.$watch("sessionStorage.getItem('OfferStore_items')", function() { console.log("New offer"); ...

Anticipate await and fulfill promises

I'm encountering issues when attempting to refactor nested Promise.all's into async/await. It seems like there might be a misunderstanding in how I should be utilizing Promise.all and await. The goal is to iterate through an array, perform an ac ...

What steps are involved in implementing Local fonts in theme UI for Next JS?

I am currently developing an application using next JS with [theme-UI][1]. However, I need to implement local or custom fonts in my project and I'm unsure of how to do this. Below is the current theming setup: const theme = { fonts: { ...