Angular响应式表单模式不起作用。
创始人
2024-10-30 07:00:40
0
  1. 确保在模块中导入了 @angular/forms:

import { ReactiveFormsModule } from '@angular/forms';

@NgModule({ imports: [ ReactiveFormsModule, // ... ], // ... }) export class AppModule { }

  1. 在组件中导入 FormGroup、FormControl 等表单相关类:

import { Component, OnInit } from '@angular/core'; import { FormGroup, FormControl } from '@angular/forms';

@Component({ selector: 'app-my-form', template:

, }) export class MyFormComponent implements OnInit { myForm: FormGroup;

ngOnInit() { this.myForm = new FormGroup({ firstName: new FormControl(), // more form controls here }); }

onSubmit() { console.log(this.myForm.value); } }

  1. 在模板中将 form 控件绑定到 FormGroup 实例:

  1. 确保 FormControlName 和 FormControl 实例的名称匹配。例如:

new FormGroup({ firstName: new FormControl(), // FormControl 实例名为 'firstName' // ... }); // FormControlName 为 'firstName'

  1. 确保 FormControl 实例有值。例如:

new FormGroup({ firstName: new FormControl(''), // FormControl 实例值为空字符串 // ... });

  1. 检查表单控件的错误信息:

热门资讯

透视ios!epoker透视底... 透视ios!epoker透视底牌(透视)开挂辅助工具(切实是有挂)-哔哩哔哩1、该软件可以轻松地帮助...
透视真的!wepoker软件安... 透视真的!wepoker软件安装包,pokemmo辅助脚本,大纲教程(总是真的有挂)-哔哩哔哩1、不...
透视app!hhpoker辅助... 透视app!hhpoker辅助码(透视)开挂辅助插件(切实是有挂)-哔哩哔哩1、进入游戏-大厅左侧-...
透视黑科技!wepoker辅助... 透视黑科技!wepoker辅助器,约局吧辅助脚本,指南书教程(真是存在有挂)-哔哩哔哩1、超多福利:...
透视存在!we poker辅助... 透视存在!we poker辅助器,wepoker怎么看底牌,烘培教程(总是是真的挂)-哔哩哔哩1、w...
透视专用!wepoker脚本下... 透视专用!wepoker脚本下载(透视)开挂辅助器(原来是有挂)-哔哩哔哩1、每一步都需要思考,不同...
透视辅助!wepoker有没有... 透视辅助!wepoker有没有插件,aapoker怎么设置抽水,攻略教程(其实是有挂)-哔哩哔哩在进...
透视必备!pokemmo辅助器... 透视必备!pokemmo辅助器手机版下载(透视)开挂辅助神器(本来是真的挂)-哔哩哔哩1)pokem...
透视安装!hhpoker底牌透... 透视安装!hhpoker底牌透视脚本,hhpoker辅助实战视频,经验教程(一直真的有挂)-哔哩哔哩...
透视实锤!aapoker怎么提... 您好,aapoker怎么提高中牌率这款游戏可以开挂的,确实是有挂的,需要了解加去威信【1367043...