来自url的Angular 2组件

问题描述 投票:0回答:1

我正在开发一个带有java微服务后端的角度5项目。其中一个微服务提供HTML页面,该页面将为另一个基于角度5的页面中的组件提供服务。但是,我似乎无法找到一种方法将HTML页面包含在角度5中作为组件。我想要做的是将页面1作为第2页中的组件包含在内,第2页将只知道第1页的URL。可以有人告诉我这样做的恰当方法是什么?

javascript html angular
1个回答
0
投票

您尚未共享文件夹结构,因此我们假设您使用angular-cli默认结构。

在src / app / app.component.html / ts / css中就像你的根组件节点。

在终端中(在src上方的一个目录中,您的整个文件夹),您可以使用angular-cli命令来创建组件。

ng g c component2 

ng g c component2/component1 

根据需要编辑component1component2 html。然后,您可以通过添加到app.component.html将它们添加到页面

<app-component2> </app-component2>

然后在component2.html

<app-component1> </app-component1>
© www.soinside.com 2019 - 2024. All rights reserved.