Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

 

 

 

Problem:

in the Angular form wird no value displayed in the input field or connected. As soon as a <form> tag is installed in the component.html page,

an Angular Material Input field no longer displays a value.

 

Solution:

you must insert a name="control" name in the input field.

 

 

<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 with <form> Tag

With the <form> tag, the <input> field in the input form does not work

The value of the ngModel variable is not displayed and not bound.

 

Cause: the name field must be inserted. The input field must have a name field

 

 

Falsch:

Works WITHOUT <form> Tag

Without <form> tag input matInput works correctly and displays values

 

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

 

Mobile

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de