如何将Angular应用程序嵌入另一个Angular应用程序 [英] How to embed Angular app inside another Angular app
问题描述
我有两个Angular项目.一个叫做 App1 ,另一个叫 Angular Form Editor .我想将 Form Editor 嵌入到 App1 (项目)中.我该怎么办?
I have two Angular projects. One is called App1, and other is Angular Form Editor. I want to embed Form Editor into App1 (project). How can I do this?
推荐答案
使用App2构建模块.
Build a module with App2.
这可能是一个复杂的任务,但是有很多模板可以使用.我创建了这个最小的模块模板-可以随时使用它: https://github.com/angular-patterns/ng-module-template
This can be a complex task but there are plenty of templates out there you can use. I created this minimal module template - feel free to use it: https://github.com/angular-patterns/ng-module-template
然后使用App1创建一个应用,并导入App2模块.确保从App2模块声明组件.
Then create an app with App1 and import the App2 module. Make sure to declare the component from the App2 module.
import 'App2Module' from 'App2Module';
@NgModule({
imports: [App2Module],
declarations: [App2Component]
})
如果您还需要一个应用程序模板,请使用以下模板:
If you also need an app template, here is one:
https://github.com/angular-patterns/ng-app-template
它使用@ngtools/webpack
表示AoT.
这篇关于如何将Angular应用程序嵌入另一个Angular应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!