Skip to content

Commit 495d633

Browse files
committed
Update documentation on how to create the icon programmatically
`ComponentFactoryResolver` is deprecated since Angular 13. Fixes #379
1 parent e654958 commit 495d633

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

docs/usage/features.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,22 +180,18 @@ Each `<fa-icon>` declared inside an `<fa-stack>` element **must** include the `s
180180

181181
### Programmatic API
182182

183-
To create `FaIconComponent` dynamically using `ComponentFactoryResolver`:
183+
To create `FaIconComponent` dynamically:
184184

185185
```ts
186186
@Component({
187187
selector: 'fa-host',
188-
template: '<ng-container #host></ng-container>'
188+
template: '<button (click)="createIcon()">Create</button><br><ng-container #host></ng-container>'
189189
})
190190
class HostComponent {
191191
@ViewChild('host', {static: true, read: ViewContainerRef}) container: ViewContainerRef;
192192

193-
constructor(private cfr: ComponentFactoryResolver) {
194-
}
195-
196193
createIcon() {
197-
const factory = this.cfr.resolveComponentFactory(FaIconComponent);
198-
const componentRef = this.container.createComponent(factory);
194+
const componentRef = this.container.createComponent(FaIconComponent);
199195
componentRef.instance.icon = faUser;
200196
// Note that FaIconComponent.render() should be called to update the
201197
// rendered SVG after setting/updating component inputs.

0 commit comments

Comments
 (0)