diff --git a/nativescript-angular/common/detached-loader.ts b/nativescript-angular/common/detached-loader.ts index 214b0caf1..cb4038584 100644 --- a/nativescript-angular/common/detached-loader.ts +++ b/nativescript-angular/common/detached-loader.ts @@ -29,7 +29,7 @@ export class DetachedLoader { // tslint:disable-line:component-class-suffix private loadInLocation(componentType: Type): Promise> { 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. @@ -52,6 +52,6 @@ export class DetachedLoader { // tslint:disable-line:component-class-suffix public loadWithFactory(factory: ComponentFactory): ComponentRef { return this.containerRef.createComponent(factory, - this.containerRef.length, this.containerRef.parentInjector, null); + this.containerRef.length, this.containerRef.injector, null); } } diff --git a/nativescript-angular/directives/dialogs.ts b/nativescript-angular/directives/dialogs.ts index 51363c032..13dde66d6 100644 --- a/nativescript-angular/directives/dialogs.ts +++ b/nativescript-angular/directives/dialogs.ts @@ -3,8 +3,8 @@ import { ComponentRef, Directive, Injectable, + Injector, NgModuleRef, - ReflectiveInjector, Type, ViewContainerRef } from "@angular/core"; @@ -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>; @@ -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) => {