Skip to content

Commit

Permalink
Merge pull request #52 from dodos90/master
Browse files Browse the repository at this point in the history
Issue 49 - Replaced ReflectiveInjector with Injector.create (Angular 16)
  • Loading branch information
sconix committed Sep 20, 2023
2 parents d413c93 + aa2b6d5 commit 63bd95d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ node_modules/
example/dist/
example/npm-debug.log
example/node_modules/
**/.DS_Store
12 changes: 7 additions & 5 deletions projects/lib/src/lib/font-picker.directive.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Directive, OnInit, OnChanges, Input, Output, EventEmitter,
import {
Directive, OnInit, OnChanges, Input, Output, EventEmitter,
HostListener, ApplicationRef, ElementRef, ChangeDetectorRef, ViewContainerRef,
SimpleChanges, ComponentFactoryResolver, Injector, ReflectiveInjector } from '@angular/core';
SimpleChanges, ComponentFactoryResolver, Injector, StaticProvider
} from '@angular/core';

import { FontInterface } from './font-picker.interfaces';

Expand Down Expand Up @@ -68,8 +70,8 @@ export class FontPickerDirective implements OnInit, OnChanges {
}

constructor(private injector: Injector, private resolver: ComponentFactoryResolver,
private appRef: ApplicationRef, private vcRef: ViewContainerRef, private elRef: ElementRef,
private cdRef: ChangeDetectorRef, private service: FontPickerService) {}
private appRef: ApplicationRef, private vcRef: ViewContainerRef, private elRef: ElementRef,
private cdRef: ChangeDetectorRef, private service: FontPickerService) {}

ngOnInit(): void {
this.fontPicker = this.fontPicker || this.fpFallbackFont;
Expand Down Expand Up @@ -126,7 +128,7 @@ export class FontPickerDirective implements OnInit, OnChanges {
}

const compFactory = this.resolver.resolveComponentFactory(FontPickerComponent);
const injector = ReflectiveInjector.fromResolvedProviders([], vcRef.parentInjector);
const injector = Injector.create({ providers: [], parent: vcRef.parentInjector });

this.dialog = vcRef.createComponent(compFactory, 0, injector, []).instance;

Expand Down

0 comments on commit 63bd95d

Please sign in to comment.