In the below component when the component is loaded in the angular4 app I keep getting the error:
ng:///HeaderModule/HeaderComponent.ngfactory.js:334
This error is emitted, if you forget to specify the name
attribute for an ngModel
.
You can find following line in your html that contains the error:
<span class="badge badge-sm up bg-danger pull-right-xs" [hidden]="notificationCount<=0" [(ngModel)]="notificationCount"></span>
As you can see, there is no name
attribute.
Use ngDefaultControl
directive to make your form has default 2way
binding
<input type="text" [(ngModel)]="name" ngDefaultControl>
in ionic 4 i had this error in my code:
<ion-label [name]="num_lable" [(ngModel)]="num_temp[i]"> {{num_temp[i]}}</ion-label>
i changed code to: (ngModel is Unnecessary in my code)
<ion-label> {{num_temp[i]}}</ion-label>
and now error not shown :)
In my case, this worked like this
Just added the name="searchInput"
Before
<input type="text" nz-input placeholder="Search Project"
[(ngModel)]="searchInput" (ngModelChange)="search()">
After
<input type="text" name="searchInput" nz-input placeholder="Search Project"
[(ngModel)]="searchInput" (ngModelChange)="search()">