Ivy: Render HTML from String / dynamic rendering
See original GitHub issueWhich @angular/* package(s) are relevant/releated to the feature request?
compiler, core, platform-browser-dynamic, platform-browser
Description
As far as I know the old aproach was to inject the JITCompiler and use it to render your HTML in an anonymous component. This worked so far. I use editable HTML in DB which uses key features as substituting variables and directives like *ngIf or *ngSwitch.
Which does not work anymore in production mode (Angular 12.x) I browsed stackoverflow and other forums to find an workarround for this and these are not working anymore (like loading the JITCompiler into Providers, which results in “JIT Compiler unavailable”.
As I found not soulution for ivy/ng 12 i considered this feature as still missing.
Best,
Malte
Proposed solution
Component to render html strings.
Example:
<render-component [html]="..." [render-data]="{ show: true}></render-component>
[html] has the following value:
"<p *ngIf=\"show\">Hello!</p>"
Which display in the case if show is true:
<p>Hello!</p>
Alternatives considered
An Service to render html on the fly.
E.g.:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:41
- Comments:22 (6 by maintainers)
Top GitHub Comments
@joseluratm
aot
have to be disabled for now.The change of
tsconfig.json
is not required.The complete component definition should be:
This is working for both dev and prod.
@nfMalde For v13, a workaround with minimum cost (bundle size) would be:
main.ts
angular.json