在Angular-7中导入某些模块时出错

时间:2019-08-30 11:44:55

标签: angular-material angular7

在Angular-7中实现MatSelectModule模块时出现以下错误。

错误:

Uncaught ReferenceError: MatSelectModule is not defined
    at app.module.ts:21

我的代码如下:

<ng-container matColumnDef="type">
      <th mat-header-cell *matHeaderCellDef> Type </th>
      <td mat-cell *matCellDef="let element"> 
        <mat-select [(ngModel)]="element.active">
          <mat-option [value]="active" *ngFor="let active of activeList">
            {{ active }}
          </mat-option>
        </mat-select>
      </td> 
    </ng-container>

我在这里使用mat-select作为下拉列表。

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 { MultipleMatTableTaskComponent } from './multiple-mat-table-task/multiple-mat-table-task.component';
import { MaterialModule } from './material.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';


@NgModule({
  declarations: [
    AppComponent,
    MultipleMatTableTaskComponent,
  ],
  imports: [
    BrowserModule,
        MaterialModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    MatSelectModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

我在这里导入MatSelectModule,但仍然显示错误。在这里,我需要使用mat-select

在组件中实现下拉列表

0 个答案:

没有答案