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. 检查表单控件的错误信息:

热门资讯

现有说明如下!aapoker辅... 现有说明如下!aapoker辅助工具安全吗,wepoker分析(透视)科普教程(新版有挂)-哔哩哔哩...
反观!wpk模拟器是什么,we... 反观!wpk模拟器是什么,wepoker辅助软件视频(透视)有挂教程(有挂详细)-哔哩哔哩1、wep...
事发当天!wepoker高级辅... 事发当天!wepoker高级辅助,cloudpoker辅助(透视)了解教程(有挂详细)-哔哩哔哩1、...
透视有挂!来玩app破解版,哈... 透视有挂!来玩app破解版,哈糖大菠萝能开挂吗(透视)曝光教程(有挂方法)-哔哩哔哩1、这是跨平台的...
据统计!wepoker怎么破解... 据统计!wepoker怎么破解游戏,wepoker正确养号方法(透视)必备教程(揭秘有挂)-哔哩哔哩...
据报道!wepoker插件程序... 据报道!wepoker插件程序激活码,aapoker透视怎么用(透视)曝光教程(有挂工具)-哔哩哔哩...
透视ai!wepoker私人局... 透视ai!wepoker私人局开挂视频,sohoo poker辅助(透视)了解教程(有挂方法)-哔哩...
辅助透视!wepokerplu... 辅助透视!wepokerplus到底是挂了吗,werplan免费挂下载(透视)推荐教程(发现有挂)-...
截至目前!aapoker透视怎... 您好,aapoker透视怎么用这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054...
透视好牌!aapoker公共底... 透视好牌!aapoker公共底牌,wepoker好友房开挂(透视)总结教程(有挂工具)-哔哩哔哩1、...