Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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 { } 
like image 804
kumara Avatar asked Aug 28 '18 08:08

kumara


People also ask

What module is Mat label in?

<input matNativeControl> & <textarea matNativeControl> <select matNativeControl> <mat-select>


1 Answers

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 { } 
like image 114
Suren Srapyan Avatar answered Sep 23 '22 13:09

Suren Srapyan