From 9329c0e8bc9615cd4bee00c22ca9c9b963d3ec47 Mon Sep 17 00:00:00 2001 From: Tobias Bosch Date: Mon, 8 Dec 2014 10:54:43 -0800 Subject: [PATCH] fix(application): also bind the root component to the injector --- modules/core/src/application.js | 4 +++- modules/core/test/application_spec.js | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/core/src/application.js b/modules/core/src/application.js index edef77c652..a9905670f2 100644 --- a/modules/core/src/application.js +++ b/modules/core/src/application.js @@ -63,7 +63,9 @@ export function documentDependentBindings(appComponentType) { bind(appRecordRangeToken).toFactory((rootView) => rootView.recordRange, [appViewToken]), bind(ChangeDetector).toFactory((appRecordRange) => - new ChangeDetector(appRecordRange), [appRecordRangeToken]) + new ChangeDetector(appRecordRange), [appRecordRangeToken]), + bind(appComponentType).toFactory((rootView) => rootView.elementInjectors[0].getComponent(), + [appViewToken]) ]; } diff --git a/modules/core/test/application_spec.js b/modules/core/test/application_spec.js index 5d5f75a728..109cf46163 100644 --- a/modules/core/test/application_spec.js +++ b/modules/core/test/application_spec.js @@ -75,6 +75,14 @@ export function main() { }); }); + it('should provide the application component in the injector', (done) => { + var injectorPromise = bootstrap(HelloRootCmp, testBindings(HelloRootCmp)); + injectorPromise.then((injector) => { + expect(injector.get(HelloRootCmp)).toBeAnInstanceOf(HelloRootCmp); + done(); + }); + }); + it('should display hello world', (done) => { var injectorPromise = bootstrap(HelloRootCmp, testBindings(HelloRootCmp)); injectorPromise.then((injector) => {