我正在做一个带有java微服务后端的angular 5项目。其中一个微服务提供一个HTML页面,该页面将为另一个基于angular 5的页面中的组件提供服务。然而,我似乎找不到一种方法将HTML页面作为组件包含在angular 5中。我想做的是将页面1作为组件包含在页面2中,页面2将只知道页面1的url。有人能告诉我这样做的合适方法是什么吗?
发布于 2017-12-14 18:44:49
你还没有分享你的文件夹结构,所以我们假设你使用的是angular-cli默认结构。
在src/app/app.component.html/ts/css中,css就像您的根组件节点。
在终端中(在src上的一个目录中,您的整个文件夹),您可以使用angular-cli命令来创建组件。
ng g c component2
ng g c component2/component1 根据需要编辑component1和component2 html。然后,您可以通过添加到app.component.html将它们添加到页面
<app-component2> </app-component2>然后在component2.html中
<app-component1> </app-component1>https://stackoverflow.com/questions/47811279
复制相似问题