I am working with Angular Material Table. In Html code, there is
<ng-container cdkColumnDef="userId">
<md-header-cell *cdkHeaderCellDef> ID </md-header-cell>
<md-cell *cdkCellDef="let row"> {{row.id}} </md-cell>
</ng-container>
I found out that cdkHeaderCellDef and cdkCellDef are from CDK Table
I am getting error saying "Can't bind to 'cdkHeaderRowDef' since it isn't a known property of 'md-header-row'."
How can I solve this ?
MatHeaderCellDef extends CdkHeaderCellDef Header cell definition for the mat-table. Captures the template of a column's header cell and as well as cell-specific properties. Selector: [matHeaderCellDef]
Instead, when objects are added, removed, or moved on the data array, you can trigger an update to the table's rendered rows by calling its renderRows() method. So you just have to call renderRows() in your refresh() method to make your changes appears.
A DataSource is simply a class that has at a minimum the following methods: connect and disconnect . The connect method will be called by the table to provide an Observable that emits the data array that should be rendered.
The cdkHeaderCellDef
and cdkCellDef
are part of the @angular/cdk
library and exported in the CdkTableModule
.
Include this module in your app's imports
import { CdkTableModule } from '@angular/cdk';
add this to the top of your component and to the top of app.module.ts and then on app.module.ts add CdkTableModule to imports as given below.
@NgModule({
declarations: [
],
imports: [
CdkTableModule
],
providers: [
],
bootstrap: [AppComponent],
})
there may be declarations and providers but in the above snippet they are ignored for convenience.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With