Für jede Instanz, wo ich versuche, den Wert in mein Formular eingegeben beziehen, bekomme ich diese komische Property 'notes' does not exist on type '{ [key: string]: AbstractControl; }'.
Fehler. Die Linie, auf die dies zurückzuführen ist, lautet 'notes': this.addForm.controls.notes.value
. Was mache ich falsch?@ eckig/Formulare FormBuilder pops Eigenschaft existiert nicht auf Typ
Hier ist der gesamte Kontext des Fehlers
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
export class TheNewClass {
addApi(): void {
if (this.addApiForm.valid) {
Api.insert({
'notes': this.addApi.controls.notes.value
});
}
}
}
Hier ist die Form, in der die Werte aus, und das Verfahren abgerufen werden, wird genannt.
<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>
können Sie etwas mehr Code teilen? – ranakrunal9
@ ranakrunal9 sicher – gh0st
Wie haben Sie 'addApi' formGroup definiert, auf das Sie innerhalb' TheNewClass' zugreifen? – ranakrunal9