Angular 库模块从工作区生成一个组件

L1g*_*ira 5 module angular-module angular-components angular angular-library

我有一个用三个项目创建的 Angular 工作区。以及我刚刚创建了一个库,我希望在其中包含可重用的模块。

通常对于项目(应用程序和库),我运行以下命令来生成模块或组件:

ng g c component componentName --project=UserPortal

ng g c component componentName --project=myLibrary

但是现在我需要向其中的模块添加组件:

例如库: projects myLibrary src lib navigation-module Add Component here

对于应用项目模块: projects UserPortal src app userModule Add Component Here

我能够通过运行在工作区的库项目中创建一个模块:

ng generate module navigation-module --project=myLibrary

目前我必须通过命令行进入该目录才能创建一个组件。但我有一种感觉,我可以像所有其他命令一样从工作区执行此操作。这将是最有益的,而不必在目录之间进行命令行排列或来回切换。

快速概览:

  1. 在 Angular 工作区中创建一个库
  2. 在 Angular 工作区的库中创建了一个模块
  3. 想要从工作区的库中的模块内创建一个组件

Fri*_*ich 13

您可以通过提供正确的路径为功能模块创建组件。在你的情况下

ng g c navigation-module/test-component --project=myLibrary
Run Code Online (Sandbox Code Playgroud)

应该做的伎俩。