【发布时间】:2019-02-21 12:26:30
【问题描述】:
Angular Material Chip 不适用于 Angular 版本 7
技术:Angular 版本 7、角度 cli、角度材料。
我想要的结果:我只想用角料芯片模块。
我做过的事情:
我已经安装了“@angular/material”:“^7.3.3”和@angular/animations”:“^7.2.6”,
-
我已将 NoopAnimationsModule 和 MatChipsModule 导入我的应用模块。
我的应用模块中的导入:
从 '@angular/platform-browser/animations' 导入 { NoopAnimationsModule, BrowserAnimationsModule };
从“@angular/material/chips”导入 { MatChipsModule }; 导入 { MatCommonModule, MatInputModule } from '@angular/material';
那么这是我的组件:
<mat-form-field>
<mat-chip-list #chipList>
<mat-chip>Chip 1</mat-chip>
<mat-chip>Chip 2</mat-chip>
</mat-chip-list>
<input [matChipInputFor]="chipList">
</mat-form-field>
我得到的错误:
应用程序运行时出现白屏,并且我的代码中出现此消息:"mat-chip-list' is not a known element"
我的代码和浏览器的屏幕截图:
【问题讨论】:
-
您是如何导入 MatChipsModule 的?确保它来自 '@angular/material/chips' 而不是其他地方(由于某种原因,有时会发生角材料)
-
@Grenther 这些是我的导入: import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations';从“@angular/material/chips”导入 { MatChipsModule };
-
我在我看到的问题中添加了一个屏幕截图
标签: angular angular-material angular-cli angular7