I need to load several components in a dynamic way. That is why I have created a parent component to do the job (depending on the value of this.rink
), like:
ngAfterViewInit() {
switch (this.rink) {
case 'ITCO':
this.templateFreetext = FreetextITCOComponent;
break;
case 'INH':
this.templateFreetext = FreetextINHComponent;
break;
default:
this.templateFreetext = FreetextBERComponent;
break;
}
const cfr = AppInjector.get(ComponentFactoryResolver);
const factory = cfr.resolveComponentFactory(this.templateFreetext);
this.componentRef = container.createComponent(factory);
this.componentRef.instance.data = data;
this.componentRef.changeDetectorRef.detectChanges();
}
This works well, but for what reason ever I'm not able to use any pipes inside the HTML template of templateFreetext
.
...
<div class="text-right text-warning">
{{ data.day | date:'EEEE, dd.MM.yyyy' }}
</div>
...
This returns Error: The pipe 'date' could not be found!
My question is now how I can use dynamic created components and pipes? What did I forget?