This post is based on the NG-CONF talk, check the talk by yourself.

 

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

1. Dynamiclly add Angular Element into your application:

Once you have angular element, then inside your new application, you can use 'docuemnt.createElement' to add it:

[Angular 8] Take away: Web Components with Angular Elements: Beyond the Basics 随笔 第1张

 

2. Lazy loading Angular element

First Register module in angular.json:

[Angular 8] Take away: Web Components with Angular Elements: Beyond the Basics 随笔 第2张

Then load with NgModuleFactoryLoader:

[Angular 8] Take away: Web Components with Angular Elements: Beyond the Basics 随笔 第3张

 

3. External elements

If you have a project A with some custom elements you want to share with other project, it is possible to bundle project A and load with other projects.

The bundle size is huge, it is not a offical way. Not recommeded yet. The bundle will be servel files, you can use tool to concat into one bundle file: https://github.com/manfredsteyer/ngx-build-plus

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄