angular - 将 @angular/material 与 Angular 9 一起使用会引发错误
问题描述
我最近将我的应用程序从 Angular 8 升级到了 Angular 9。
今天我尝试安装 Angular Material。我按照官方说明使用ng add @angular/material
,然后导入MatChipsModule
。
但是启动应用程序会出现以下错误(是的,我尝试删除 node_modules 并从头开始安装所有内容):
上述错误是针对 MatAutoCompleteModule 的,但对于所有角度材料模块,我都会遇到相同的错误。
我正在运行 Angular 9.1.2 版和 Angular Material 9.2.3 版。
我在其中导入材料模块的 Angular 模块:
const contactsEffects = [
ContactEffects,
ContactSalesMeetingsEffects,
ConsentsEffects,
ContactSearchProfileEffects,
];
@NgModule({
imports: [
EffectsModule.forFeature(contactsEffects),
CommonModule,
ReactiveFormsModule,
ModalModule,
TooltipModule,
ProgressbarModule,
BsDropdownModule,
TranslateModule,
MomentModule,
SkeletonScreenModule,
ContactsRoutingModule,
NguiMapModule,
ActionListModule,
CreateContactModule,
ListComponentsModule,
UiComponentsModule,
ResourceModule,
UtilModule,
SidebarSharedModule,
ContactActionsWidgetModule,
HintModule,
FormComponentsModule,
AddContactToCallingListModule,
MatChipsModule,
MatAutocompleteModule,
MatFormFieldModule,
],
exports: [
ContactCardDetailsComponent,
CreateNoteComponent,
ContactNextStepComponent,
ContactActionsWidgetComponent,
ContactOverviewComponent,
],
declarations: [
ContactsComponent,
ContactOverviewComponent,
ContactActionsComponent,
ContactNextStepComponent,
ContactNextStepListItemComponent,
ContactResidencesComponent,
ContactResidenceComponent,
ContactCardDetailsComponent,
CreateNoteComponent,
ProfileProgressModalComponent,
ContactCardDetailsComponent,
ContactSalesMeetingsComponent,
ContactSalesMeetingsListItemComponent,
ContactSalesMeetingsDetailCardComponent,
ContactSalesMeetingsDetailEmptyComponent,
ContactInfoRowComponent,
ContactsSalesMeetingsNoEditModalComponent,
ContactCardActionsComponent,
CreateNewResidenceModalComponent,
ContactOwnsResidenceComponent,
ProfileResidenceMenuItemComponent,
ContactCardDetailsLoadingComponent,
ContactNextStepLoadingComponent,
CallListModeHeaderComponent,
ContactConsentsComponent,
ConsentsListComponent,
ConsentsSidebarComponent,
ContactSearchProfilePageComponent,
SearchProfileCardComponent,
SearchProfileDetailsComponent,
RelatedObjectsCardComponent,
RelatedObjectItemComponent,
SurveysModalComponent,
NpsDetailsModalComponent,
ContactTagsComponent,
],
providers: [ContactOverviewEffects],
})
export class ContactsModule {}
解决方案
事实证明,我的 Angular 和 Material 版本不兼容。对于 Angular 9.1.2 版,我必须使用 angular/material 9.1.0 版。
推荐阅读
- git - .gitignore 不忽略文件夹内的文件
- javascript - Laravel 翻译文件中的 Javascript 调用
- mysql - 我尝试获取一些按日期、编号排序的数据,并获取每件商品的最新价格
- android - 无法在 Android 应用上播放此视频错误
- javascript - Chrome 提示出现过快
- python - 字符串问题/在熊猫数据框中选择所有值> 8000
- python - 如何使 Jupyter Notebook 指向与 Ubuntu 上的终端相同的 Python 安装?
- azure - 登录 Azure 应用服务运行实例
- c - 将 D 项目编译为库 - 依赖项会发生什么?
- php - 如何使用 php 从 URL 中获取第三个字符串