【问题标题】:how to solve 'mat-list-option' is an Angular component?如何解决“mat-list-option”是一个 Angular 组件?
【发布时间】:2019-06-25 13:00:27
【问题描述】:

我已经尝试了互联网上的所有内容,但似乎没有任何东西可以解决我的错误。

这是我的 NgModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { AppComponent } from './app.component';
import { MDBBootstrapModule } from 'angular-bootstrap-md';
import { FormsModule } from '@angular/forms';
import { MainLayoutComponent } from './MainLayout/main-layout/main-layout.component';
import { AppRoutingModule } from './app-routing.module';
import { ContainersPageComponent } from './Containers/containers-page/containers-page.component';

import { HttpClientModule } from '@angular/common/http';
import { MatTableModule } from '@angular/material/table';
import { MarinServiceService } from './services/marin-service.service';
import { MatPaginatorModule, MatSortModule, MatInputModule, MatSelectModule, MatFormFieldModule } from '@angular/material';



@NgModule({
  declarations: [
    AppComponent,
    MainLayoutComponent,
    ContainersPageComponent,

  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    MDBBootstrapModule.forRoot(),
    FormsModule,
    AppRoutingModule,
    HttpClientModule,
    MatTableModule,
    MatPaginatorModule,
    MatSortModule,
    MatInputModule,
    MatSelectModule,
    MatFormFieldModule,

  ],
  providers: [MarinServiceService],
  bootstrap: [AppComponent]
})
export class AppModule { }

这是我得到的确切错误:

)
: 'mat-selection-list' is not a known element:
1. If 'mat-selection-list' is an Angular component, then verify that it is part of this module.
2. If 'mat-selection-list' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("

  <!--Check Box Search-->
  [ERROR ->]<mat-selection-list >
    <mat-list-option >

我尝试过重新导入,但没有成功。 我已尝试导入所有与 Mat 相关的内容。

我真的不知道问题出在哪里。

【问题讨论】:

  • 我认为您的意思是 'mat-list-option' 不是 Angular 组件? 可能包括错误的堆栈跟踪,以及你实现它的模板?
  • 您实际遇到的确切错误是什么?

标签: html angular typescript angular-material material-design


【解决方案1】:

你需要导入MatListModule

import {MatListModule} from '@angular/material/list';

将其添加到 app.module.ts

的导入数组下

【讨论】:

    【解决方案2】:

    您需要在相关模块中导入Mat List Module。

    import {MatListModule} from '@angular/material/list';

    更多信息:https://material.angular.io/components/list/api

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-29
      • 1970-01-01
      • 2019-12-28
      • 2019-04-25
      • 1970-01-01
      • 2019-08-04
      • 2019-02-02
      • 1970-01-01
      相关资源
      最近更新 更多