docs: update forwardRef example (#39519)
Replace the deprecated api ReflectiveInjector.resolveAndCreat with Injector.create PR Close #39519
This commit is contained in:
parent
eaace44d57
commit
ad62edac9c
@ -6,7 +6,7 @@
|
|||||||
* found in the LICENSE file at https://angular.io/license
|
* 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', () => {
|
describe('forwardRef examples', () => {
|
||||||
@ -34,10 +34,11 @@ import {forwardRef, Inject, ReflectiveInjector, resolveForwardRef} from '@angula
|
|||||||
// Only at this point Lock is defined.
|
// Only at this point Lock is defined.
|
||||||
class Lock {}
|
class Lock {}
|
||||||
|
|
||||||
const injector = ReflectiveInjector.resolveAndCreate([Door, Lock]);
|
const injector =
|
||||||
const door = injector.get(Door);
|
Injector.create({providers: [{provide: Lock, deps: []}, {provide: Door, deps: [Lock]}]});
|
||||||
expect(door instanceof Door).toBeTruthy();
|
|
||||||
expect(door.lock instanceof Lock).toBeTruthy();
|
expect(injector.get(Door) instanceof Door).toBe(true);
|
||||||
|
expect(injector.get(Door).lock instanceof Lock).toBe(true);
|
||||||
// #enddocregion
|
// #enddocregion
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user