Answer the question
In order to leave comments, you need to log in
How to solve undefined' is not assignable to type 'CdkTableDataSourceInput' error and why did it occur?
Good day!
Angular Material has been implemented in the project.
In the component template, I am trying to display the table in tasks (the table markup is taken from https://material.angular.io/components/table/overview ).
In the component I do: dataSource?: MatTableDataSource An
error occurs: Type 'MatTableDataSource | undefined' is not assignable to type 'CdkTableDataSourceInput'
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8">
dataSource: MatTableDataSource<Task> = new MatTableDataSource([])
public dataSource?: MatTableDataSource<Task> = new MatTableDataSource<Task>([]);
Answer the question
In order to leave comments, you need to log in
Everything is written in the error: the type of MatTableDataSource does not match the type of CdkTableDataSourceInput. Apparently you are trying to pass a field of the MatTableDataSource type to the component, this is your dataSource, and it expects a parameter of the CdkTableDataSourceInput type.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question