Angular Material component not working: 'mat-option' is not a known element

Discussão em 'Angular' iniciado por kumara, Julho 31, 2025.

  1. kumara

    kumara Guest

    I am trying to add angular material component. but the component did not work properly. that error said

    Uncaught Error: Template parse errors: 'mat-option' is not a known element:
    // ...


    I think the error comes from app.module.ts:

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';

    import { AppRoutingModule } from './app-routing.module';
    import { AppComponent } from './app.component';
    import { SidebarComponent } from './sidebar/sidebar.component';
    import { PostsComponent } from './posts/posts.component';
    import { UsersComponent } from './users/users.component';
    import { DetailsComponent } from './details/details.component';
    import { HttpClientModule } from '@angular/common/http';
    import { FooterComponent } from './footer/footer.component';
    import {MatButtonModule, MatCheckboxModule} from '@angular/material';
    import {MatFormFieldModule} from '@angular/material/form-field';
    import { MyFormComponent } from './my-form/my-form.component';
    @NgModule({
    declarations: [
    AppComponent,
    SidebarComponent,
    PostsComponent,
    UsersComponent,
    DetailsComponent,
    FooterComponent, MyFormComponent
    ],
    imports: [
    BrowserModule, AppRoutingModule,HttpClientModule,MatButtonModule, MatCheckboxModule,MatFormFieldModule
    ]
    providers: [],
    bootstrap: [AppComponent]
    })
    export class AppModule { }

    Continue reading...

Compartilhe esta Página