I have Angular 5 application with several environments (dev, qa, customer1, customer2, etc.). Using environment.xxx.ts
I get runtime configuration variables with no problem. However, I can't conditionally include a template during compilation. That is, I would like to have something like that:
@Component({
selector: 'app-hello',
templateUrl: `hello.component.${environment.client}.html`
})
where environment.client
is provided by environment.customer1.ts
.
Maybe it's a bigger question - how can I control template or stylesheet in Component's metadata.
NOTE 1: I realize that soon we will get Ivy renderer that will allow to combine AOT and JIT compilers; but I am not trying to load the template dynamically - only compile the right template depending on the environment.
NOTE 2: I tried dotenv
, but it seems to work the same way: it gives me control of the environment variables at runtime, but doesn't help to choose the right file for compilation.