Angular MonoRepo Nx - 在应用程序中使用库

Angular MonoRepo Nx - use library in application

情况: 我是 Angular 的新手,想创建一个包含多个应用程序和库的 Angular 工作区。我按照 this tutorial 以 MonoRepo 的形式使用 Nx 创建了一个 Angular 工作区。我按照教程中介绍的步骤创建了一个应用程序和一个库。

所以我有一个名为 first-app 的应用程序和一个名为 first-lib 的库。在 first-lib 中,我有一个组件 first-lib-component。我想在我的第一个 app.html:

中像这样使用组件或最好的库本身
<h2> This is my first-app </h2>
<first-lib></first-lib> OR
<first-lib-component></first-lib-component>

我已经在 app.module.ts 中导入了 first-lib 并将 first-lib-module 添加到导入中。

问题: 我想在我创建的应用程序中使用创建的库,这就是我目前失败的地方。我收到一条错误消息,指出“'first-lib-component' 不是已知元素”。

Nx website 指出:

... the clients of the library are in the same repository, so no packaging and publishing step is required.

如果不需要打包,我如何使用我共享的components/projects(库)?

我的问题: 如何在应用程序中导入和使用库(的组件)?

需要将组件添加到模块并导出,然后将该模块导入到您的应用程序中。