Reputation: 32507
I would like to be able to create developer purpose components that would provide some usefull debugging information (for example eg internal state of the component) which could be included into the application views just like any other component but only if this is not a production environment. It would be something like
<my-component #subject></my-component>
<ng-container *ngIf='!isProduction'>
<dev-debug-inspector [subject]="subject"></dev-debug-inspector>
</ng-container>
Is it possible ?
Upvotes: 1
Views: 51
Reputation: 23793
It's definitely possible to lazy load a component based on some conditions without using the router.
Example:
public lazyDevComponent = null;
constructor() {
if (!isProduction) {
this.lazyDevComponent = import(`../routing-step-details-per-types/types/cam/cam.component`).then(
({ CamComponent }) => CamComponent,
);
}
}
and on TS side:
<ng-template
*ngIf="lazyDevComponent"
[ngComponentOutlet]="lazyDevComponent"
></ng-template>
Upvotes: 2