Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Migrate from ReflectiveInjector (deprecated) to StaticInjector (#1868)
* chore: migrate to StaticInjector * chore: replace parentInjector in detached-loader
  • Loading branch information
edusperoni authored and Zdravko committed Jun 28, 2019
commit 5042e089c57c9224865f38f73a2e8636b63063ee
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