我有一个4角组件的表格。这些字段是动态生成的,即使用ngFor生成输入。输入是不同类型的,例如复选框,文字...
在ts代码中,我怎么知道输入控件的类型?
HTML
<form *ngIf="active" #easyForm="ngForm" (ngSubmit)="onSubmit()">
<div *ngFor="let i in items">
<input type="text" name="text-{{item.id}}" [(ngModel)]="item.text">
<input type="checkbox" name="checkbox-{{item.id}} (ngModel)]="item.checked">
</div>
</form>
TS
@ViewChild('easyForm') set content(easyForm: NgForm) {
this.easyForm = easyForm;
if (this.easyForm) {
const keys = Object.keys(this.easyForm.controls);
foreach(let key in keys) {
this.easyForm.controls[key] <---- am i able to get the type of the control here?
}
}