Ошибка сборки Angular 6. Ожидалось 0 аргументов, но получено 1 в форме

Я получаю эту ошибку: Ожидается 0 аргументов, но получен 1, когда я создаю свой проект, но на ng-serve с проектом все в порядке? Есть идеи, что это может быть? ошибка указывает на: (ngSubmit) = "onSubmit(serviceForm.value)"

мой html:

<form class = "form-horizontal" [formGroup] = "serviceForm" (ngSubmit) = "onSubmit(serviceForm.value)">
      <div class = "form-group mb-8">
        <div class = "col-3 col-sm-12">
          <label class = "form-label" for = "u_message_description">Please describe your issue:</label>
        </div>
        <div class = "col-4 col-sm-12">
          <textarea class = "form-input" id = "u_message_description" placeholder = "Describe your issue" rows = "3"
            formControlName = "u_message_description"></textarea>
          <h6 class = "text-gray mt-2">The more information you can provide here, the easier time the organization will
            have in diagnosing and resolving your issue.</h6>
        </div>
      </div>

      <div class = "columns col-12 col-sm-12">
        <div class = "column col-10 col-sm-6 text-right">
          <button class = "btn btn-link">Cancel</button>
        </div>
        <div class = "column col-2 col-sm-6">
          <button class = "btn btn-primary" [ngClass] = "{'loading': uploading}" [disabled] = "!serviceForm.valid" type = "submit">Submit</button>
        </div>
      </div>
    </form>

Компонент.ts

import { Component, OnInit } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { FormGroup, FormControl } from '@angular/forms';
import { Validators } from '@angular/forms';
import { FormBuilder } from '@angular/forms';
import { Request } from '../../models/request.model'
import { Router } from '@angular/router';
import { Observable } from 'rxjs';
import { AppComponent } from '../../../app.component';
import { nowService } from '../../services/servicenow.service';
import { HttpClient, HttpEventType, HttpHeaders, HttpRequest, HttpResponse } from '@angular/common/http';


@Component({
  selector: 'app-service-request',
  templateUrl: './service-request.component.html',
  styleUrls: ['./service-request.component.scss']
})
export class ServiceRequestComponent implements OnInit {


  public loading = false;

  public uploading: boolean;

  private customer_id = 7; /// this.appComponent.customer_id;

  serviceForm;

  constructor(private service: nowService,
    private appComponent: AppComponent,
    private router: Router,
    private http: HttpClient,
  ) {
  }

  ngOnInit() {
    this.serviceForm = new FormGroup({
      u_short_description: new FormControl('', Validators.compose([
        Validators.required,
        Validators.minLength(0),
        Validators.maxLength(80)
      ])),
      u_message_description: new FormControl(''),
    });
  }

   onSubmit() {
    if (this.serviceForm.invalid) {
       this.serviceForm.setErrors({ ...this.serviceForm.errors, 'required': true });
       return;
    }
    //this.loading = true;
    this.uploading = true;
    this.service.postFormData(this.serviceForm.value).subscribe((response: any) => {
      console.info(response);//On success response
      this.router.navigate(['/inc/confirmation'],{queryParams: {value: response.result[0].display_value}});
    }, (errorResponse: any) => {
      console.info(errorResponse); //On unsuccessful response
    });
    }
  }

сервис.тс

postFormData(payload) {
    return this.http.post(this.incidentApiUrl, payload, { headers: new HttpHeaders().set("Content-Type", "application/json") });
  }
Тестирование функциональных ngrx-эффектов в Angular 16 с помощью Jest
В системе управления состояниями ngrx, совместимой с Angular 16, появились функциональные эффекты. Это здорово и делает код определенно легче для...
Angular и React для вашего проекта веб-разработки?
Angular и React для вашего проекта веб-разработки?
Когда дело доходит до веб-разработки, выбор правильного front-end фреймворка имеет решающее значение. Angular и React - два самых популярных...
Эпизод 23/17: Twitter Space о будущем Angular, Tiny Conf
Эпизод 23/17: Twitter Space о будущем Angular, Tiny Conf
Мы провели Twitter Space, обсудив несколько проблем, связанных с последними дополнениями в Angular. Также прошла Angular Tiny Conf с 25 докладами.
Угловой продивер
Угловой продивер
Оригинал этой статьи на турецком языке. ChatGPT используется только для перевода на английский язык.
Мое недавнее углубление в Angular
Мое недавнее углубление в Angular
Недавно я провел некоторое время, изучая фреймворк Angular, и я хотел поделиться своим опытом со всеми вами. Как человек, который любит глубоко...
Освоение Observables и Subjects в Rxjs:
Освоение Observables и Subjects в Rxjs:
Давайте начнем с основ и постепенно перейдем к более продвинутым концепциям в RxJS в Angular
0
0
6 230
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Ваш метод «onSubmit()» не требует аргументов. Но из вашего html вы вызываете его с одним аргументом: "onSubmit(serviceForm.value)"

Я бы удалил параметр из html, просто используя onSubmit()

Другие вопросы по теме