I want to dynamically create a template. This should be used to build a ComponentType
at runtime and place (even replace) it somewhere inside of the ho
Following up on Radmin's excellent answer, there is a little tweak needed for everyone who is using angular-cli version 1.0.0-beta.22 and above.
COMPILER_PROVIDERS
can no longer be imported (for details see angular-cli GitHub).
So the workaround there is to not use COMPILER_PROVIDERS
and JitCompiler
in the providers
section at all, but use JitCompilerFactory
from '@angular/compiler' instead like this inside the type builder class:
private compiler: Compiler = new JitCompilerFactory([{useDebug: false, useJit: true}]).createCompiler();
As you can see, it is not injectable and thus has no dependencies with the DI. This solution should also work for projects not using angular-cli.