Problem: im Angular Formular wird kein Wert im Input
Feld angezeigt oder angebunden.
Problem:
im Angular Formular wird kein Wert im Input Feld
angezeigt oder angebunden. Sobald ein <form> Tag in der component.html Seite
eingebaut wird,
zeigt ein Angular Material Input Feld keinen Wert mehr
an.
Lösung:
man muss im Input Feld eine name="control"
benennung einfügen.
<form novalidate #f="ngForm">
<div >
<p>value_string:={{value_string}}</p>
<mat-form-field style="width:400px">
<mat-label>input string:</mat-label>
<input matInput name="ctlString" [(ngModel)]="value_string">
</mat-form-field>
</div>
<div>
<p>value_string_time:={{value_string_time}}</p>
<mat-form-field>
<mat-label>input time:</mat-label>
<input matInput type="time" name="ctlTime" [(ngModel)]="value_string_time">
</mat-form-field>
</div>
</form>
|
Angular mit <form> Tag
Mit dem <form> tag funktioniert das <input>
feld in dem Eingabeformular nicht
Der Wert der ngModel Variable wird nicht angezeigt und
nicht gebunden.
Ursache: das name Feld muss eingefügt werden. Das
Inputfeld muss ein name Feld aufweisen
Falsch:
Funktioniert OHNE <form> Tag
Ohne <form> tag funktioniert input matInput
richtig und zeigt werte an
error TS2304: Cannot find name 'NgForm'
'Creates a top-level FormGroup
instance and binds it to a form to track
aggregate form value and validation
@angular/forms