Angular – Can't bind to 'ngValue' since it isn't a known property of 'mat-option'

Issue

I’m using angular 5 and I’m getting the console error:

Can’t bind to ‘ngValue’ since it isn’t a known property of
‘mat-option’

My template looks something like as follows:

  <mat-select placeholder="Select Book" name="patient" [(ngModel)]="selectedBook">
     <mat-option *ngFor="let eachBook of books" [ngValue]="eachBook">{{eachBook.name}}</mat-option>
  </mat-select>

I’ve imported both MatSelectModule and MatOptionModule.

How can we resolve this?

Solution

You should use value

[value]="eachBook"

Answered By – Sajeetharan

Answer Checked By – Mildred Charles (AngularFixing Admin)

Leave a Reply

Your email address will not be published.