Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Angular ERROR: NG01352: If ngModel is used within a form tag, either the name attribute must be set or the form

06.02.2023 (👁3265)

Angular ERROR: NG01352: If ngModel is used within a form tag, either the name attribute must be set or the form


Problem: Der Wert wird im Feld nicht angezeigt und es kommt eine Fehlermeldung in Developer Angular

edit-article.component.ts:117 ERROR Error: NG01352: If ngModel is used within a form tag, either the name attribute must be set or the form

    control must be defined as 'standalone' in ngModelOptions.

 

    Example 1: <input [(ngModel)]="person.firstName" name="first">

    Example 2: <input [(ngModel)]="person.firstName" [ngModelOptions]="{standalone: true}">

 

Lösung:
man muss nur ein name="meinFeld" in das Tag einfügen

<form #f="ngForm" (ngSubmit)="save_create()">

    <div *ngIf="article">

        <h1>Id:{{idarticle}}</h1>

 

        <input [(ngModel)]="article.title" name="title" placeholder="Title" style="width: 100%" />

        <button class="btn mat-raised-button btn-primary" [disabled]="!f.valid" >Save</button>

        <button (click)="delete_article(idarticle)" *ngIf="idarticle">Delete</button>

    </div>

 

</form>