angular - Angular 模块导入和组件使用
问题描述
我有一个如图所示的目录结构
https://i.stack.imgur.com/yitTd.png
当我在app.component.html<app-news-card>
使用选择器时,它显示错误<app-news-card> not present in current module.
我应该如何以最实用的方式解决这个问题。
目前:我是
1.)从news.module 中导出news- card.component
2.) 然后我在current.module中导入NewsModule并重新导出NewsModule
3.)然后我在app.module中导入了CurrentModule
解决方案
确保news card
您的news.module
. 例如:
@NgModule({
declarations: [NewsCardComponent],
imports: [...],
exports: [NewsCardComponent]
})
更多关于 boostrap 的信息可以在这里找到:Docs
推荐阅读
- pyinstaller - 未使用 pyinstaller 加载的软件包
- java - 基于 LinkedHashMap 的字符串可能排列?
- c++ - 矩阵类内存分配和重载
- python - 测试两个pathlib.Paths的casefolded相等性的最简单方法?
- java - 如何在底部导航栏中删除标题标题 - Android Studio
- python - 创建一个接受两个整数参数的python函数,查找它们之间的所有素数并在列表中返回这些素数
- assembly - 减小 NASM 汇编可执行文件大小
- google-sheets - 将 gatsby-source-google-spreadsheet 插件与 GatsBy 一起使用时,数字在 GraphQL 中被转换为字符串
- json - 回调 URL 未接收 JSON 数据
- mysql - MySQL Workbench 错误代码:添加检查约束时出现 3819