angular - 反应式表单不显示在 html 中
问题描述
我有以下代码。但是表格没有显示出来。有人可以让我知道这段代码有什么问题吗?
<tfoot>
<form [formGroup]="profileForm" (ngSubmit)="onSubmit()">
<tr>
<td>
<input class="form-control" type="text" formControlName="type" />
</td>
<td>
<ng-select [items]="parameterType" formControlName="parametertype" [clearable]="false" bindLabel="text" bindValue="id"></ng-select>
</td>
<td>
<ng-select [items]="defaultValues" formControlName="defaultValue" [clearable]="false" bindLabel="text" bindValue="id"></ng-select>
</td>
<td>
<input formControlName="description" class="form-control" type="text" />
</td>
<td>
<button type="submit" [disabled]="!profileForm.valid">
Submit
</button>
</td>
</tr>
</form>
这是我在组件中的方法。
ngOnInit() {
this.profileForm = this._formBuilder.group({
'type': ['', [Validators.required, Validators.minLength(5)]],
'parametertype': ['', [Validators.required, Validators.minLength(5)]],
'defaultValue': ['', [Validators.required, Validators.minLength(5)]],
'description': ['', [Validators.required, Validators.minLength(5)]]
});
}
解决方案
这对我有用
<tfoot [formGroup]="profileForm" (ngSubmit)="onSubmit()">
推荐阅读
- c# - 当我在“IIS”上发布我的应用程序时收到 400 - 错误请求,但在发布之前它运行良好
- python - 如何在python中选择异步或同步方法变体?
- php - 通过 PHP 从 Unity 上传图像并将其存储在文件夹中
- text - 更改长度属性时,SwiftUI 文本不适合
- python - 排除数组中不包含特定小数的元素
- android - 如何用凌空解决“我的请求执行了两次”?
- typescript - 如何在不编译为 JS 的情况下使用用 TypeScript 编写的自定义 tslint 规则和 vscode-tslint?
- shell - 投影随机图像/蒙太奇
- junit5 - 我们如何在 MicronautTest 类中为同一个控制器运行多个测试?
- c++ - 线程的 C++ 向量在加入时随机崩溃