Anonymous
Ngsubmit не работает
Сообщение
Anonymous » 30 май 2025, 15:56
У меня есть форма Angular 4, в которой я пытаюсь отправить данные < /p>
html -код < /strong> < /p>
Код: Выделить всё
Scheduler
Schedule Job
< /code>
код кнопки < /strong> < /p>
Cancel
Submit
< /code>
scheduler.ts file < /strong> < /p>
import { Component, OnInit } from '@angular/core';
import { Scheduler } from 'rxjs/Scheduler';
/* Import FormControl first */
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-scheduler',
templateUrl: './scheduler.component.html',
styleUrls: ['./scheduler.component.css']
})
export class SchedulerComponent implements OnInit {
//Gender list for the select control element
private scheduleTypeList: string[];
//Property for the user
private scheduler:Scheduler;
private signupForm: FormGroup;
constructor(private fb:FormBuilder) { }
ngOnInit() {
this.scheduleTypeList = ['Type 1', 'Type 2', 'Type 3'];
this.signupForm = this.fb.group({
schedulejob: ['', Validators.required] ,
frequency: ['', Validators.required],
days: ['', Validators.required],
zone: ['', Validators.required],
schedulerjobtype:['', Validators.required]
})
}
public onFormSubmit() {
this.scheduler = this.signupForm.value;
if(this.signupForm.valid) {
this.scheduler = this.signupForm.value;
console.log(this.scheduler);
// alert(this.scheduler);
/* Any API call logic via services goes here */
}
//alert(this.scheduler);
console.log(this.scheduler);
}
}
Почему выполнение не передается в OnformSubmit при отправке Click and Alert или Console.log не печатает значения?
Подробнее здесь:
https://stackoverflow.com/questions/506 ... ot-working
1748609773
Anonymous
У меня есть форма Angular 4, в которой я пытаюсь отправить данные < /p> html -код < /strong> < /p> [code] Scheduler Schedule Job < /code> код кнопки < /strong> < /p> Cancel Submit < /code> scheduler.ts file < /strong> < /p> import { Component, OnInit } from '@angular/core'; import { Scheduler } from 'rxjs/Scheduler'; /* Import FormControl first */ import { FormBuilder, FormGroup, Validators } from '@angular/forms'; @Component({ selector: 'app-scheduler', templateUrl: './scheduler.component.html', styleUrls: ['./scheduler.component.css'] }) export class SchedulerComponent implements OnInit { //Gender list for the select control element private scheduleTypeList: string[]; //Property for the user private scheduler:Scheduler; private signupForm: FormGroup; constructor(private fb:FormBuilder) { } ngOnInit() { this.scheduleTypeList = ['Type 1', 'Type 2', 'Type 3']; this.signupForm = this.fb.group({ schedulejob: ['', Validators.required] , frequency: ['', Validators.required], days: ['', Validators.required], zone: ['', Validators.required], schedulerjobtype:['', Validators.required] }) } public onFormSubmit() { this.scheduler = this.signupForm.value; if(this.signupForm.valid) { this.scheduler = this.signupForm.value; console.log(this.scheduler); // alert(this.scheduler); /* Any API call logic via services goes here */ } //alert(this.scheduler); console.log(this.scheduler); } } [/code] Почему выполнение не передается в OnformSubmit при отправке Click and Alert или Console.log не печатает значения? Подробнее здесь: [url]https://stackoverflow.com/questions/50637044/ngsubmit-not-working[/url]