将 @angular/material 与 Angular 9 一起使用会引发错误
Using @angular/material with Angular 9 throws errors
我最近将我的应用程序从 Angular 8 升级到 Angular 9。
今天我尝试安装 Angular Material。我按照官方说明使用 ng add @angular/material
然后导入 MatChipsModule
.
但是启动应用程序会出现以下错误(是的,我尝试删除 node_modules 并从头开始安装所有内容):
以上错误是针对 MatAutoCompleteModule 的,但我对所有 angular material 模块都遇到相同的错误。
我是 运行 Angular 版本 9.1.2 和 Angular Material 版本 9.2.3。
我的 Angular 模块,我在其中导入 Material 模块:
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.
我最近将我的应用程序从 Angular 8 升级到 Angular 9。
今天我尝试安装 Angular Material。我按照官方说明使用 ng add @angular/material
然后导入 MatChipsModule
.
但是启动应用程序会出现以下错误(是的,我尝试删除 node_modules 并从头开始安装所有内容):
以上错误是针对 MatAutoCompleteModule 的,但我对所有 angular material 模块都遇到相同的错误。
我是 运行 Angular 版本 9.1.2 和 Angular Material 版本 9.2.3。
我的 Angular 模块,我在其中导入 Material 模块:
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.