feat: allow for forward references in injection
It is possible for a class defined first to be referencing a class defined later, and as a result at the time of the definition it is not possible to access the later's class reference. This allows to refer to the later defined class through a closure.Closes #1891
This commit is contained in:
23
modules/angular2/test/di/forward_ref_spec.js
vendored
Normal file
23
modules/angular2/test/di/forward_ref_spec.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
import {
|
||||
AsyncTestCompleter,
|
||||
beforeEach,
|
||||
ddescribe,
|
||||
describe,
|
||||
expect,
|
||||
iit,
|
||||
inject,
|
||||
it,
|
||||
xit,
|
||||
} from 'angular2/test_lib';
|
||||
import {forwardRef, resolveForwardRef} from 'angular2/di';
|
||||
import {Type} from 'angular2/src/facade/lang';
|
||||
|
||||
export function main() {
|
||||
describe("forwardRef", function () {
|
||||
it('should wrap and unwrap the reference', () => {
|
||||
var ref = forwardRef(() => String);
|
||||
expect(ref instanceof Type).toBe(true);
|
||||
expect(resolveForwardRef(ref)).toBe(String);
|
||||
});
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user