角 8 上有一个表格我的form.component.html<div class="container"><form novalidate [formGroup]="registrationForm"> <div class="form-group"> <label for="firstName">Имя:</label> <input #spy required pattern=[A-Za-zА-Яа-яЁё]{2,} name="firstName" id="firstName" type="text" class="form-control" formControlName="firstName"> </div> <div class="form-group"> <label for="lastName">Фамилия:</label> <input #spy required pattern=[A-Za-zА-Яа-яЁё]{2,} name="lastName" id="lastName" type="text" class="form-control" formControlName="lastName"> </div> <div class="form-group"> <label for="email">E-mail:</label> <input #spy required email name="email" id="email" type="email" class="form-control" formControlName="email"> </div> <!--{{ spy.className }}--> <button type="submit" class="btn btn-succes" (click)="submit(myForm)">Отправить</button></form>当用户写入数据时,提交按钮应使用 POST 方法向 API 发送数据。如果您需要任何代码,请发表评论ts 代码:import { FormGroup, FormControl } from '@angular/forms';import {HttpClient} from '@angular/common/http';@Component({ selector: 'app-my-form', templateUrl: './my-form.component.html', styleUrls: ['./my-form.component.css']})export class MyFormComponent implements OnInit { registrationForm: FormGroup; constructor() { } ngOnInit() { this.registrationForm = new FormGroup({ firstName: new FormControl(), lastName: new FormControl(), email: new FormControl() }); }}```
添加回答
举报
0/150
提交
取消