Skip to content

Commit

Permalink
fix(modal): don't use deprecated 'ReflectiveInjector'
Browse files Browse the repository at this point in the history
Closes #2285
  • Loading branch information
maxokorokov authored and pkozlowski-opensource committed Apr 9, 2018
1 parent d76100a commit 0f8055f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/modal/modal-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
Injectable,
Injector,
Inject,
ReflectiveInjector,
ComponentFactory,
ComponentFactoryResolver,
ComponentRef,
Expand Down Expand Up @@ -119,8 +118,7 @@ export class NgbModalStack {
moduleCFR: ComponentFactoryResolver, contentInjector: Injector, content: any,
context: NgbActiveModal): ContentRef {
const contentCmptFactory = moduleCFR.resolveComponentFactory(content);
const modalContentInjector =
ReflectiveInjector.resolveAndCreate([{provide: NgbActiveModal, useValue: context}], contentInjector);
const modalContentInjector = Injector.create([{provide: NgbActiveModal, useValue: context}], contentInjector);
const componentRef = contentCmptFactory.create(modalContentInjector);
this._applicationRef.attachView(componentRef.hostView);
return new ContentRef([[componentRef.location.nativeElement]], componentRef.hostView, componentRef);
Expand Down
4 changes: 2 additions & 2 deletions src/modal/modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
NgModule,
getDebugNode,
DebugElement,
ReflectiveInjector
Injector
} from '@angular/core';
import {CommonModule} from '@angular/common';
import {TestBed, ComponentFixture} from '@angular/core/testing';
Expand Down Expand Up @@ -515,7 +515,7 @@ describe('ngb-modal', () => {
describe('custom injector option', () => {

it('should render modal with a custom injector', () => {
const customInjector = ReflectiveInjector.resolveAndCreate([CustomSpyService]);
const customInjector = Injector.create([{provide: CustomSpyService, useClass: CustomSpyService, deps: []}]);
const modalInstance = fixture.componentInstance.openCmpt(CustomInjectorCmpt, {injector: customInjector});
fixture.detectChanges();
expect(fixture.nativeElement).toHaveModal('Some content');
Expand Down

0 comments on commit 0f8055f

Please sign in to comment.