Why do my Angular Material components are not existing in the template, even though they are imported in the component decorator?

I’m currently working on an Angular project which was created via the Angular CLI. Additionally I wanted to use the Angular Material Framework. At first there were no issues with using the provided components. Unfortunately at some point my template suddenly does’nt know the Angular Material components anymore. Here are some of the errors I get:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>mat-grid-list' is not a known element:
1. If 'mat-grid-list' is an Angular component, then verify that it is included in the '@Component.imports' of this component.
2. If 'mat-grid-list' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@Component.schemas' of this component to suppress this message.ngtsc(-998001)
app.component.ts(18, 2): Error occurs in the template of component AppComponent.
</code>
<code>mat-grid-list' is not a known element: 1. If 'mat-grid-list' is an Angular component, then verify that it is included in the '@Component.imports' of this component. 2. If 'mat-grid-list' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@Component.schemas' of this component to suppress this message.ngtsc(-998001) app.component.ts(18, 2): Error occurs in the template of component AppComponent. </code>
mat-grid-list' is not a known element:
1. If 'mat-grid-list' is an Angular component, then verify that it is included in the '@Component.imports' of this component.
2. If 'mat-grid-list' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@Component.schemas' of this component to suppress this message.ngtsc(-998001)
app.component.ts(18, 2): Error occurs in the template of component AppComponent.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>Can't bind to 'dataSource' since it isn't a known property of 'table'.ngtsc(-998002)
app.component.ts(18, 2): Error occurs in the template of component AppComponent.
</code>
<code>Can't bind to 'dataSource' since it isn't a known property of 'table'.ngtsc(-998002) app.component.ts(18, 2): Error occurs in the template of component AppComponent. </code>
Can't bind to 'dataSource' since it isn't a known property of 'table'.ngtsc(-998002)
app.component.ts(18, 2): Error occurs in the template of component AppComponent.

Now you probably think that the project would crash if you try to build it. But strangely it builds without any problems and even display the components correctly.

Unluckily the attributes and functions of the Angular Material components like the [dataSource] attribute from the mat-table do not work because of that.

As you can see I imported all necessary modules and components in my component decorator:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import { Component, OnInit } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { RouterModule } from '@angular/router';
import { MatTableModule } from '@angular/material/table';
import { MatCardModule } from '@angular/material/card';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatButtonModule } from '@angular/material/button';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-root',
standalone: true,
imports: [
RouterModule,
RouterOutlet,
CommonModule,
MatButtonModule,
MatGridListModule,
MatCardModule,
MatTableModule,
],
providers: [
],
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
})
export class AppComponent{
title = 'Title';
// More properties here...
</code>
<code>import { Component, OnInit } from '@angular/core'; import { RouterOutlet } from '@angular/router'; import { RouterModule } from '@angular/router'; import { MatTableModule } from '@angular/material/table'; import { MatCardModule } from '@angular/material/card'; import { MatGridListModule } from '@angular/material/grid-list'; import { MatButtonModule } from '@angular/material/button'; import { CommonModule } from '@angular/common'; @Component({ selector: 'app-root', standalone: true, imports: [ RouterModule, RouterOutlet, CommonModule, MatButtonModule, MatGridListModule, MatCardModule, MatTableModule, ], providers: [ ], templateUrl: './app.component.html', styleUrl: './app.component.scss', }) export class AppComponent{ title = 'Title'; // More properties here... </code>
import { Component, OnInit } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { RouterModule } from '@angular/router';
import { MatTableModule } from '@angular/material/table';
import { MatCardModule } from '@angular/material/card';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatButtonModule } from '@angular/material/button';
import { CommonModule } from '@angular/common';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [
    RouterModule,
    RouterOutlet,
    CommonModule,
    MatButtonModule,
    MatGridListModule,
    MatCardModule,
    MatTableModule,
  ],
  providers: [
  ],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss',
})
export class AppComponent{
  title = 'Title';
  // More properties here...

Normally with that I should be able to use the imported components like the mat-table or mat-card.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code><mat-card>
<mat-card-content>
// Content here...
</mat-card-content>
</mat-card>
</code>
<code><mat-card> <mat-card-content> // Content here... </mat-card-content> </mat-card> </code>
<mat-card> 
    <mat-card-content>

        // Content here...

    </mat-card-content>  
</mat-card>

But when trying to use them, I get the already provided errors and can’t use the attributes of the components.

To fix the problem I tried to update and reinstall Angular Material. Additionally I tried to delete my cache and recreate the files. This sadly didn’t work for me.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật