I cannot submit angular reactive form in a ngb modal Angular 7

I cannot submit angular reactive form in a ngb modal Angular 7

Content Index :

I cannot submit angular reactive form in a ngb modal Angular 7
Tag : html , By : KL.
Date : November 24 2020, 12:01 PM

seems to work fine Your component doesn't know which modal to close. You need to pass the NgbModal reference to the submission function.
 <form [formGroup]="addForm" (ngSubmit)="onSubmit(content)">
onSubmit(modal: NgbModal) {
    modal.dismiss(); // Add wherever you need
<form [formGroup]="addForm" (ngSubmit)="onSubmit()" #f="ngForm"> /* Last attribute added */
@ViewChild('f') ngForm: NgForm;

No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Angular testing submit event on reactive form

Tag : angular , By : Diego
Date : March 29 2020, 07:55 AM
I hope this helps . Context , First option is calling ngSubmit directly:
.triggerEventHandler('ngSubmit', null); 
      declarations: [
      imports: [ReactiveFormsModule], // <== import it
      providers: []

Angular 7 : How do I submit file/image along with my reactive form?

Tag : angular , By : Icyflash
Date : March 29 2020, 07:55 AM
wish helps you Had this issue too, what I did was to construct a FormData, the using a loop add the formGroup values to the form Data
import {
} from '@angular/core';
import {
} from '@angular/forms';

export class TodoFormComponent {
  todoForm: FormGroup = this.fb.group({
    todo: ['', Validators.required],
    image: ['', Validators.required], //making the image required here
    done: [false]

    private fb: FormBuilder,
    private cd: ChangeDetectorRef
  ) {}

   *@param event {EventObject} - the javascript change event
   *@param field {String} - the form field control name
  onFileChange(event, field) {
    if (event.target.files && event.target.files.length) {
      const [file] = event.target.files;
      // just checking if it is an image, ignore if you want
      if (!file.type.startsWith('image')) {
          required: true
      } else {
        // unlike most tutorials, i am using the actual Blob/file object instead of the data-url
          [field]: file
        // need to run CD since file load runs outside of zone

    onSubmit() {
      const formData = new FormData();
        ([key, value]: any[]) => {
          formData.set(key, value);

        //submit the form using formData
        // if you are using nodejs use something like multer

<form [formGroup]="todoForm" (ngSubmit)="onSubmit()">
  <input type="file" formControlName="image" (onchange)="onFileChange($event, 'image')"/>
  <textarea formControlName="todo"></textarea>
  <button type="submit">Submit</button>

How to Submit an Angular reactive form programmatically?

Tag : angular , By : Luciano Campos
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Instead of the (ngSubmit)="onSubmit($event)" you'd have a method in your component TS file. It would look something like this:
Component TS file
addPatientAndContinue() {
    var formValue = this.patientInfoForm.value;
    // Submit the form data via a service (or HttpClient)
    // "Continue"

addPatient() {
    var formValue = this.patientInfoForm.value;
    // Submit the form data via a service (or HttpClient)
<button id="add" (click)="addPatientAndContinue()">Add Patient & Continue</button>
<button id="addngo" (click)="addPatient()">Add Patient</button>

Angular 8 Reactive Form dynamic Edit/Add modal validation

Tag : angular , By : Keonne Rodriguez
Date : March 29 2020, 07:55 AM
hop of those help? What i did to resolve this after cleaning a lot of code, i call my modal passing some args, the modal reference, editMode status and the index of the data, what i did is to setValue() to the form and pass the data from the array, this way it fill the inputs with the selected data and the data pass all validations requirements.
onReceiverModal(modal, editMode?: boolean, index?: number) {
this.editReceiver = editMode;
if (editMode) {
this.editReceiverIndex = index;
this.modalService.open(modal, {
  size: 'lg',
  windowClass: 'dark-modal'

Is it possible to get all errors after submit reactive form in angular

Tag : angular , By : Chaz
Date : March 29 2020, 07:55 AM
hope this fix your issue As long as this functionality is not shipped with original library you can create a small sub-library that does that. What you need is to extend original classes that return you the errors.
import { AbstractControl, FormArray, FormGroup as OriginalFormGroup } from '@angular/forms';

class FormGroup extends OriginalFormGroup {

  // create a getter allErrors
  // returns an object of sub-controls' errors
  get allErrors() { 
    return Object
      .keys(this.controls) // go through all the control names
      .reduce((result, name) => {
        const control = <FormGroup | AbstractControl>this.controls[name];

        // if control is FormGroup recursively call its `allErrors`
        if (control instanceof FormGroup) {
          result[name] = control.allErrors;
        } else if (control instanceof FormArray) {
          // add implementation for array here
        } else {
          // for normal controls add errors here
          result[name] = control.errors;

        return result; // and return the result to the next control
      }, {});

import { FormGroup } from './my-forms';

this.form = new FormGroup() // all as usually but using your FormGroup

Related Posts Related QUESTIONS :
  • Is there an application I can show a client the speed of their site via differring internet connections?
  • Html / Email / Distribution list problem from a noob
  • Inspiring web experiments and technical demos
  • Can I load javascript code using <link> tag?
  • Lisp-style quotation in HTML
  • How to put text float around image like some newspapers' format using CSS?
  • Technical reasons for not having large background images in websites
  • HTML 5 Structure tags demo
  • Angular - String interpolation of undefined variable
  • Is there any way to edit specific Column of table using mat-table in Angular material
  • How can I set a text as a shadow for a heading element?
  • How to fix the forms making the buttons overlap
  • Splitting XML into multiple HTML pages with XSLT?
  • How to justify empty divs in flex container
  • How to blur in CSS only one layer of when you have multiple layers in background-image?
  • Scrollable html table with fixed first row and first column, along with angular material controls within the cells of ta
  • In Django, how to extract ID attribute from html Input tag, WITHOUT using django forms
  • how to fix link tag in html after changing css
  • How do I add a top padding to the second row?
  • Is it possible to split XML into multiple HTML pages with page navigation?
  • AngularJS: responsive height in bootstrap
  • Hide second line of text with CSS
  • repeating-linear-gradient not working in Edge browser and internet Explorer Browser
  • how to make search and form category merges like amazon on bootstrap
  • Bootstrap: Rearranging rows into columns and changing the order of elements
  • How can I move a label under a text box?
  • How save LinearGradient To database
  • How to reposition an image with a linear gradient using css?
  • HTML audio will not play when page opened by batch file
  • CSS Three Tone Diagonal Background
  • How to use slots inside of template components in HTML
  • Using span tags in meta description & title, for dual languages
  • How to make an icon/span selectable by pressing Tab key?
  • Add dynamic margins using UI Kit
  • Add margin-top to textbox
  • What is the correct semantic HTML markup for a title (book, movie, etc.), according to the spec? Is it an <em> tag
  • How to make an animation in Geoserver or in Leaflet
  • Buttons overlapping when shrinking window
  • Stretch an element to the end of the automatically calculated grid, not just the explicit grid
  • What relation is there between Angular's <ng-content> and ShadowDOM
  • CSS background for div element is not working
  • CSS Marquee: multiple paragraphs overlaps
  • I want to align search bar to extreme right
  • Getting blank white space to the left of content inside pre tags
  • My viewer.html won't load any css and jss files
  • How to apply multiple styles to HTML to only part of a title?
  • Want to make text div transparent on a parallax area
  • Is there a way to make this ID plus descendants CSS rule less specific?
  • Is there a way to drop in a stylesheet to get a Material theme or similar for all form elements on the page?
  • How do I make a sideways L look in html/css?
  • Why won't the color #e67d22e1 display in Safari?
  • How to select specific tag's attribute value with xPath?
  • How to make div rows fill available height
  • How to fix text inside a block that grows
  • svg hexagon halftone pattern
  • How to edit a website's element's background colors using a chromium extention
  • What is the main tag in HTML5 ? How does it differ from body tag?
  • My image is flowing out from my div column. How I can fix it and made the image full-size into div
  • How to draw line in react
  • Why Transition css is not working in child selector css
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com