【问题标题】:Angular workspaces interactionAngular 工作区交互
【发布时间】:2018-08-17 15:55:52
【问题描述】:

我正在使用 Angular 6。

假设我有 angular 6 项目和 2 个附加项目(不是库),描述如下:

Project1 : 有一个组件 app-project1

Project2 : 有一个组件 app-project2

在默认项目 app-root 中,我想像这样使用 app-project1app-project2

app-root的模板:

<h1> The first project </h1>
<app-project1></app-project1>
<h1> The second project </h1>
<app-project2></app-project2>

当我执行 ng serve 时,我收到错误消息说 app-project1app-project2 不是已知组件。

我的问题是 Angular 6 项目如何相互通信或与默认项目通信。

【问题讨论】:

    标签: angular angular6 angular-cli-v6


    【解决方案1】:

    如果您想重用旧项目组件,您应该架构旧项目 使用Sharing Modules 方法的组件现在你 可以重复使用分片模块,只需将其复制并粘贴到当前项目中并 import 它在 app-root

    Creating a Library with the Angular CLI

    【讨论】:

    • 感谢您的回复,这是共享模块的旧方式。我想使用 Angular v6 中添加的新工作区功能。
    • @Nour 好吧,我想这篇文章会对你有所帮助blog.angularindepth.com/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-14
    • 2020-09-15
    • 2017-08-26
    相关资源
    最近更新 更多