FortAwesome / angular-fontawesome

Official Angular component for Font Awesome 5+
https://fontawesome.com
MIT License
1.49k stars 152 forks source link

Icon cannot be created dynamically #365

Closed montella1507 closed 2 years ago

montella1507 commented 2 years ago

Regular directive code:

` ngAfterViewInit(): void { // Resolve FA icon component const factory = this.factoryComponentResolver.resolveComponentFactory(FaIconComponent); // i thought the problem is with injector - so i tried to use injector that has all configurations required.. directive is in the same module that has FaModule imported and all icons loaded (icon works when i put it diretcly to html) const componentRef = this.viewContainer.createComponent(factory, 0, this.injector); (componentRef.location.nativeElement as HTMLElement).classList.add("clear"); componentRef.instance.icon = ['fas', 'times']; componentRef.changeDetectorRef.detectChanges(); }

`

Result is empty FA element: image

So maybe htere is problem with Fa-icon component implementation (its one time binding there?)

montella1507 commented 2 years ago

Ah, there is function render() that has to be called. Ok so maybe i can close.