Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular VS代码/角度-过梁不';无法识别通过共享模块导入的组件_Angular_Visual Studio Code_Angular Module - Fatal编程技术网

Angular VS代码/角度-过梁不';无法识别通过共享模块导入的组件

Angular VS代码/角度-过梁不';无法识别通过共享模块导入的组件,angular,visual-studio-code,angular-module,Angular,Visual Studio Code,Angular Module,因此,我在我的项目中有一个共享模块,其中包括导入我所有的角度材质模块。我的代码构建和运行都很好。问题在于,在我的html文件中,在vs代码中,我在每个Angle materials组件标记下都有红色的曲线,错误如下: '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-selec

因此,我在我的项目中有一个共享模块,其中包括导入我所有的角度材质模块。我的代码构建和运行都很好。问题在于,在我的html文件中,在vs代码中,我在每个Angle materials组件标记下都有红色的曲线,错误如下:

'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

product.module.ts


谢谢查看。

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


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

我找到了它。我还安装了nativescript,并使用@src路径导入共享模块,正如它所建议的:

import { SharedModule } from '@src/app/shared/shared.module';
一旦我将其还原为使用相对路径:

import { SharedModule } from '../../shared/shared.module';

一切都开始正常工作。

我正在从“共享”模块导出模块,以便我的所有其他模块都可以导入一个模块并获得所有常用导入。这样我就不必在不同的模块中多次导入MatFormFieldModule。
import { SharedModule } from '@src/app/shared/shared.module';
import { SharedModule } from '../../shared/shared.module';