docs: update forwardRef example (#39519)

Replace the deprecated api ReflectiveInjector.resolveAndCreat with Injector.create

PR Close #39519
This commit is contained in:
Eduard Bondarenko 2020-10-31 13:06:49 +02:00 committed by Joey Perrott
parent eaace44d57
commit ad62edac9c
1 changed files with 6 additions and 5 deletions

View File

@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.io/license
*/
import {forwardRef, Inject, ReflectiveInjector, resolveForwardRef} from '@angular/core';
import {forwardRef, Inject, Injector, resolveForwardRef} from '@angular/core';
{
describe('forwardRef examples', () => {
@ -34,10 +34,11 @@ import {forwardRef, Inject, ReflectiveInjector, resolveForwardRef} from '@angula
// Only at this point Lock is defined.
class Lock {}
const injector = ReflectiveInjector.resolveAndCreate([Door, Lock]);
const door = injector.get(Door);
expect(door instanceof Door).toBeTruthy();
expect(door.lock instanceof Lock).toBeTruthy();
const injector =
Injector.create({providers: [{provide: Lock, deps: []}, {provide: Door, deps: [Lock]}]});
expect(injector.get(Door) instanceof Door).toBe(true);
expect(injector.get(Door).lock instanceof Lock).toBe(true);
// #enddocregion
});