对于我尝试引用输入到我的表单中的值的每个实例,我都会收到这个有趣的Property 'notes' does not exist on type '{ [key: string]: AbstractControl; }'.错误。造成这种情况的线是'notes': this.addForm.controls.notes.value。我究竟做错了什么?
这是错误的整个上下文
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
export class TheNewClass {
addApi(): void {
if (this.addApiForm.valid) {
Api.insert({
'notes': this.addApi.controls.notes.value
});
}
}
}
这是从中检索值和调用方法的形式。
<form [formGroup]="addApiForm" (ngSubmit)="addApi()" class="inline-form">
<div class="form-group">
<label for="apiNotes">Notes</label>
<input id="apiNotes" formControlName="apiNotes" class="form-control" type="text" placeholder="Notes">
</div>
<button type="submit" class="btn btn-primary">Add</button>
</form>