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 { }
<input matNativeControl> & <textarea matNativeControl> <select matNativeControl> <mat-select>
You need to import MatSelectModule
cause mat-option
are declared inside this module and add this into the AppModule
imports
import { ..., MatSelectModule, ... } from '@angular/material'; @NgModule({ imports: [ ..., MatSelectModule, ...] }) export class AppModule { }
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