Skip to content

Migrate from ReflectiveInjector (deprecated) to StaticInjector #1868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nativescript-angular/common/detached-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class DetachedLoader { // tslint:disable-line:component-class-suffix
private loadInLocation(componentType: Type<any>): Promise<ComponentRef<any>> {
const factory = this.resolver.resolveComponentFactory(componentType);
const componentRef = this.containerRef.createComponent(
factory, this.containerRef.length, this.containerRef.parentInjector);
factory, this.containerRef.length, this.containerRef.injector);

// Component is created, built may not be checked if we are loading
// inside component with OnPush CD strategy. Mark us for check to be sure CD will reach us.
Expand All @@ -52,6 +52,6 @@ export class DetachedLoader { // tslint:disable-line:component-class-suffix

public loadWithFactory<T>(factory: ComponentFactory<T>): ComponentRef<T> {
return this.containerRef.createComponent(factory,
this.containerRef.length, this.containerRef.parentInjector, null);
this.containerRef.length, this.containerRef.injector, null);
}
}
12 changes: 6 additions & 6 deletions nativescript-angular/directives/dialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
ComponentRef,
Directive,
Injectable,
Injector,
NgModuleRef,
ReflectiveInjector,
Type,
ViewContainerRef
} from "@angular/core";
Expand All @@ -18,7 +18,7 @@ import { DetachedLoader } from "../common/detached-loader";
import { PageFactory, PAGE_FACTORY } from "../platform-providers";
import { once } from "../common/utils";
import { topmost, Frame } from "tns-core-modules/ui/frame";
import { ShowModalOptions } from "tns-core-modules/ui/core/view";
import { ShowModalOptions } from "tns-core-modules/ui/core/view";

export type BaseShowModalOptions = Pick<ShowModalOptions, Exclude<keyof ShowModalOptions, "closeCallback" | "context">>;

Expand Down Expand Up @@ -126,11 +126,11 @@ export class ModalDialogService {
});

const modalParams = new ModalDialogParams(options.context, closeCallback);
const providers = ReflectiveInjector.resolve([
{ provide: ModalDialogParams, useValue: modalParams },
]);

const childInjector = ReflectiveInjector.fromResolvedProviders(providers, options.containerRef.parentInjector);
const childInjector = Injector.create({
providers: [{ provide: ModalDialogParams, useValue: modalParams }],
parent: options.containerRef.injector
});
const detachedFactory = options.resolver.resolveComponentFactory(DetachedLoader);
detachedLoaderRef = options.containerRef.createComponent(detachedFactory, -1, childInjector, null);
detachedLoaderRef.instance.loadComponent(options.type).then((compRef) => {
Expand Down