【发布时间】:2020-01-17 20:15:03
【问题描述】:
所以我的项目中有一个共享模块,其中我要导入我所有的 Angular 材料模块。我的代码构建并运行得很好。问题是,在我的 html 文件中,在 vs 代码中,我在每个角度材料组件标记下都有红色波浪线,并出现错误:
'mat-select' is not a known element:
1. If 'mat-select' is an Angular component, then verify that it is part of this module.
2. If 'mat-select' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.ng(0)
我已尝试重新启动 IDE。如果我将材料模块直接导入我的模块,而不是通过共享模块,该消息确实会消失。无论如何,这是我的代码:
shared.module.ts
...
@NgModule({
imports: [
CommonModule,
ReactiveFormsModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
FlexLayoutModule,
MatListModule,
MatSelectModule,
MatSidenavModule,
MatToolbarModule
],
exports:
[
ReactiveFormsModule,
MatFormFieldModule,
MatIconModule,
MatInputModule,
FlexLayoutModule,
MatListModule,
MatSelectModule,
MatSidenavModule,
MatToolbarModule
]
})
export class SharedModule { }
product.module.ts
...
@NgModule({
declarations: [
ProductComponent,
ProductFormComponent,
AddProductToStoreFormComponent,
StorePickerComponent,
StorePickerRootComponent,
SizeFormComponent,
CategoryPickerRootComponent,
CategoryPickerComponent
],
imports: [
CommonModule,
ProductRoutingModule,
SharedModule
]
})
export class ProductModule { }
感谢收看。
【问题讨论】:
标签: angular visual-studio-code angular-module