VS代码/ Angular-Linter无法识别通过共享模块导入的组件

问题描述 投票:0回答:1

因此,我的项目中有一个共享模块,除其他外,我将导入所有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 { }

感谢您的光临。

javascript angular visual-studio-code angular-module
1个回答
0
投票

您为什么在导出部分中导出其他模块?导出允许其他模块访问声明您的模块的组件/管道。不是模块。

因此,在product.module.ts中,导入MatFormFieldModule

© www.soinside.com 2019 - 2024. All rights reserved.