Angular

Can’t bind to ‘ngmodel’ since it isn’t a known property of ‘input’. angular 8

Error in angular at console gives

can’t bind to ‘ngmodel’ since it isn’t a known property of ‘input’. angular 8

in xyz.component .html code must be like

<div  class="form-group">
    <div class="form-group">
        <label>Name of Category</label>
        <input type="text" name="category"  class="form-control" [(ngModel)]="category">
    </div>

    <div class="form-group">
        <label>Category Detail</label>
        <textarea name="category_detail"  class="form-control" [(ngModel)]="category_detail"></textarea>
    </div>
    <button class="btn btn-primary" (click)="onAddCategory()">Add Category</button>
</div>

mind the code : [(ngModel)]=”category”

In app.module.ts

there must be added FormsModule.

import { FormsModule } from ‘@angular/forms’;

imports: [ FormsModule]

Leave a Reply

Your email address will not be published. Required fields are marked *